Patchwork [4,of,8] templater: add revtags function

login
register
mail settings
Submitter timeless@mozdev.org
Date Sept. 11, 2015, 3:36 a.m.
Message ID <17cd87686306199b0f78.1441942602@waste.org>
Download mbox | patch
Permalink /patch/10481/
State Rejected
Headers show

Comments

timeless@mozdev.org - Sept. 11, 2015, 3:36 a.m.
# HG changeset patch
# User timeless@mozdev.org
# Date 1441936251 14400
#      Thu Sep 10 21:50:51 2015 -0400
# Node ID 17cd87686306199b0f78748f5180602a56acd4a2
# Parent  227e1da16f2910dc058c18cb3ddbd69cc16deaa5
templater: add revtags function

revtags takes a revision and returns its tags

for use like:
  {revset("...") % "{revision|revtags}"}

Patch

diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -568,6 +568,15 @@ 
     files = modified + added + removed
     return templatekw.showlist("file", files, **mapping)
 
+def revtags(context, mapping, args):
+    """:revtags(rev): Show tags.
+    See :hg:`help templates.tags`."""
+    ctx, repo = ctxrepo('revtags', context, mapping, args)
+    namespace = 'tags'
+    ns = repo.names[namespace]
+    names = ns.names(repo, ctx.node())
+    return names
+
 def revset(context, mapping, args):
     """:revset(query[, formatargs...]): Execute a revision set query. See
     :hg:`help revset`."""
@@ -766,6 +775,7 @@ 
     "revdesc": revdesc,
     "revfiles": revfiles,
     "revset": revset,
+    "revtags": revtags,
     "rstdoc": rstdoc,
     "shortest": shortest,
     "startswith": startswith,
diff --git a/tests/test-log.t b/tests/test-log.t
--- a/tests/test-log.t
+++ b/tests/test-log.t
@@ -2106,6 +2106,9 @@ 
   changeset:	1
   files:	A B C
   
+  $ hg log -r 0 --template '{revset("2::2") % "tag:\t\t{revision|revtags}\n"}\n'
+  tag:		tip
+  
   $ hg log -r . --template '{revdesc()}'
   hg: parse error: revdesc expects one argument
   [255]