[PATCH] templatekw: clarify the result of {latesttag} when no tag exists

Matt Harbison mharbison72 at gmail.com
Sun Apr 9 00:26:29 EDT 2017


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1491711054 14400
#      Sun Apr 09 00:10:54 2017 -0400
# Node ID 8b5a325adc7a011fbbed18886290684793ff8a35
# Parent  42c7df6da065e310c5685fbba2799ffe77d73afd
templatekw: clarify the result of {latesttag} when no tag exists

My initial expectation was that the list would be empty, and therefore
detectable with {if()}.  The map for {latesttag()} is populated with real values
in this case (except {tag}), so it probably doesn't make any sense to change
this to an empty list.

diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -432,7 +432,8 @@
 @templatekeyword('latesttag')
 def showlatesttag(**args):
     """List of strings. The global tags on the most recent globally
-    tagged ancestor of this changeset.
+    tagged ancestor of this changeset.  If no such tags exist, the list
+    consists of the single string "null".
     """
     return showlatesttags(None, **args)
 
diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -719,7 +719,9 @@
 @templatefunc('latesttag([pattern])')
 def latesttag(context, mapping, args):
     """The global tags matching the given pattern on the
-    most recent globally tagged ancestor of this changeset."""
+    most recent globally tagged ancestor of this changeset.
+    If no such tags exist, the "{tag}" template resolves to
+    the string "null"."""
     if len(args) > 1:
         # i18n: "latesttag" is a keyword
         raise error.ParseError(_("latesttag expects at most one argument"))


More information about the Mercurial-devel mailing list