# HG changeset patch # User Matt Harbison # Date 1436238744 14400 # Node ID b44e483726d30456d71693e757c1f928f577c193 # Parent f5f43178bdde98f0ffd5aa3f2d3cede974d9b95f 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. diff -r f5f43178bdde -r b44e483726d3 mercurial/templatekw.py --- 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)