[PATCH 2 of 2] templatekw: make {latesttag} a hybrid list
Matt Harbison
mharbison72 at gmail.com
Tue Jul 7 17:14:53 CDT 2015
# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1436239402 14400
# Mon Jul 06 23:23:22 2015 -0400
# Node ID 9ddcfcbafedffc7aee3ff45486283f32c62129fd
# Parent 4234e8fdb6e672a065a2727347608ff2a91bfc9c
templatekw: make {latesttag} a hybrid list
This maintains the previous behavior of expanding {latesttag} to a string
containing all of the tags, joined by ':'. But now it also allows list type
operations.
I'm unsure if the plural handling is correct (i.e. it seems like it is usually
"{foos % '{foo}'}"), but I guess we are stuck with this because the singular
form previously existed.
diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -325,11 +325,15 @@
"""
return showlist('file', args['ctx'].files(), **args)
-def showlatesttag(repo, ctx, templ, cache, **args):
- """:latesttag: String. Most recent global tag in the ancestors of this
- changeset.
+def showlatesttag(**args):
+ """:latesttag: List of strings. The global tags on the most recent globally
+ tagged ancestor of this changeset.
"""
- return ':'.join(getlatesttags(repo, ctx, cache)[2])
+ repo, ctx, templ = args['repo'], args['ctx'], args['templ']
+ cache = args['cache']
+ latesttags = getlatesttags(repo, ctx, cache)[2]
+
+ return showlist('latesttag', latesttags, separator=':', **args)
def showlatesttagdistance(repo, ctx, templ, cache, **args):
""":latesttagdistance: Integer. Longest path to the latest tag."""
diff --git a/tests/test-tag.t b/tests/test-tag.t
--- a/tests/test-tag.t
+++ b/tests/test-tag.t
@@ -447,6 +447,9 @@
$ echo c4 > f4
$ hg log -r '.' -T "{latesttag}\n"
t4:t6
+ $ hg log -r '.' -T "{latesttag % '{latesttag}\n'}"
+ t4
+ t6
$ hg ci -A -m4
adding f4
$ hg tag t2
More information about the Mercurial-devel
mailing list