diff mercurial/templatekw.py @ 25726:b44e483726d3

templatekw: allow the caller of showlist() to specify the join() separator The keyword {latesttag} currently manually joins the list of tags using ':', which prevents a transparent switch over to a hybrid list.
author Matt Harbison <matt_harbison@yahoo.com>
date Mon, 06 Jul 2015 23:12:24 -0400
parents 4474a750413f
children b8245386ab40
line wrap: on
line diff
--- a/mercurial/templatekw.py	Tue Jun 30 23:56:49 2015 -0400
+++ b/mercurial/templatekw.py	Mon Jul 06 23:12:24 2015 -0400
@@ -40,24 +40,25 @@
             raise AttributeError(name)
         return getattr(self.values, name)
 
-def showlist(name, values, plural=None, element=None, **args):
+def showlist(name, values, plural=None, element=None, separator=' ', **args):
     if not element:
         element = name
-    f = _showlist(name, values, plural, **args)
+    f = _showlist(name, values, plural, separator, **args)
     return _hybrid(f, values, lambda x: {element: x})
 
-def _showlist(name, values, plural=None, **args):
+def _showlist(name, values, plural=None, separator=' ', **args):
     '''expand set of values.
     name is name of key in template map.
     values is list of strings or dicts.
     plural is plural of name, if not simply name + 's'.
+    separator is used to join values as a string
 
     expansion works like this, given name 'foo'.
 
     if values is empty, expand 'no_foos'.
 
     if 'foo' not in template map, return values as a string,
-    joined by space.
+    joined by 'separator'.
 
     expand 'start_foos'.
 
@@ -77,7 +78,7 @@
         return
     if name not in templ:
         if isinstance(values[0], str):
-            yield ' '.join(values)
+            yield separator.join(values)
         else:
             for v in values:
                 yield dict(v, **args)