--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -310,6 +310,7 @@ common_filters = {
"strip": lambda x: x.strip(),
"urlescape": lambda x: urllib.quote(x),
"user": lambda x: util.shortuser(x),
+ "stringescape": lambda x: x.encode('string_escape'),
}
def templatepath(name=None):
@@ -431,14 +432,15 @@ class changeset_templater(object):
if endname in self.t:
yield self.t(endname, **args)
- if brinfo:
- def showbranches(**args):
- if changenode in brinfo:
- for x in showlist('branch', brinfo[changenode],
- plural='branches', **args):
- yield x
- else:
- showbranches = ''
+ def showbranches(**args):
+ branch = changes[5].get("branch")
+ if branch:
+ yield showlist('branch', [branch], plural='branches', **args)
+ # add old style branches if requested
+ if brinfo and changenode in brinfo:
+ for x in showlist('branch', brinfo[changenode],
+ plural='branches', **args):
+ yield x
if self.ui.debugflag:
def showmanifest(**args):
@@ -463,6 +465,14 @@ class changeset_templater(object):
for x in showlist('tag', self.repo.nodetags(changenode), **args):
yield x
+ def showextras(**args):
+ extras = changes[5].items()
+ extras.sort()
+ for key, value in extras:
+ args = args.copy()
+ args.update(dict(key=key, value=value))
+ yield self.t('extra', **args)
+
if self.ui.debugflag:
files = self.repo.status(log.parents(changenode)[0], changenode)[:3]
def showfiles(**args):
@@ -498,6 +508,7 @@ class changeset_templater(object):
'parents': showparents,
'rev': rev,
'tags': showtags,
+ 'extras': showextras,
}
props = props.copy()
props.update(defprops)