mercurial/templatekw.py
changeset 18970 3cdb6f2f6789
parent 18715 c4ff927b6f68
child 20015 ad27cdacc743
child 20076 faa4b3fc4197
--- a/mercurial/templatekw.py	Wed Apr 10 02:27:35 2013 +0900
+++ b/mercurial/templatekw.py	Tue Apr 16 09:44:29 2013 -0500
@@ -14,9 +14,13 @@
 #  "{files % '{file}\n'}" (hgweb-style with inlining and function support)
 
 class _hybrid(object):
-    def __init__(self, gen, values):
+    def __init__(self, gen, values, joinfmt=None):
         self.gen = gen
         self.values = values
+        if joinfmt:
+            self.joinfmt = joinfmt
+        else:
+            self.joinfmt = lambda x: x.values()[0]
     def __iter__(self):
         return self.gen
     def __call__(self):
@@ -245,7 +249,7 @@
 
     c = [{'name': x[0], 'source': x[1]} for x in copies]
     f = _showlist('file_copy', c, plural='file_copies', **args)
-    return _hybrid(f, c)
+    return _hybrid(f, c, lambda x: '%s (%s)' % (x['name'], x['source']))
 
 # showfilecopiesswitch() displays file copies only if copy records are
 # provided before calling the templater, usually with a --copies
@@ -257,7 +261,7 @@
     copies = args['revcache'].get('copies') or []
     c = [{'name': x[0], 'source': x[1]} for x in copies]
     f = _showlist('file_copy', c, plural='file_copies', **args)
-    return _hybrid(f, c)
+    return _hybrid(f, c, lambda x: '%s (%s)' % (x['name'], x['source']))
 
 def showfiledels(**args):
     """:file_dels: List of strings. Files removed by this changeset."""