Patchwork [5,of,7] templatekw: add helper method to generate a template keyword for a namespace

login
register
mail settings
Submitter Sean Farley
Date Dec. 17, 2014, 12:01 a.m.
Message ID <3c155bf2bd32e0b719f6.1418774519@laptop.local>
Download mbox | patch
Permalink /patch/7133/
State Superseded
Commit 40fcf6c0521781ef981f0490d71712f1ac27c135
Headers show

Comments

Sean Farley - Dec. 17, 2014, 12:01 a.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1418613337 28800
#      Sun Dec 14 19:15:37 2014 -0800
# Node ID 3c155bf2bd32e0b719f6fe4dc66c635b2e87b40e
# Parent  540c8c40fd3cd46b26092acd1d88cb4525b3e9ef
templatekw: add helper method to generate a template keyword for a namespace

Patch

diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -376,10 +376,18 @@  def showsubrepos(**args):
 
 def showtags(**args):
     """:tags: List of strings. Any tags associated with the changeset."""
     return showlist('tag', args['ctx'].tags(), **args)
 
+def shownames(namespace, **args):
+    """helper method to generate a template keyword for a namespace"""
+    ctx = args['ctx']
+    repo = ctx._repo
+    names = repo.names.names(repo, namespace, ctx.node())
+    return showlist(repo.names.singular(namespace), names, plural=namespace,
+                    **args)
+
 # keywords are callables like:
 # fn(repo, ctx, templ, cache, revcache, **args)
 # with:
 # repo - current repository instance
 # ctx - the changectx being displayed