diff mercurial/templater.py @ 10061:9e2ab10728a2

Make {file_copies} usable as a --template key Before this, to display file copies in templates, you had to write something like {file_copies%filecopy}. For some reason, the {file_copy} subtemplate was used by default but not defined by default in changeset_templater, while styles were already using it. Here we define {file_copy} in changeset_templater, and change the templater to handle formatting strings like {file_copies%filecopy} with already expanded keys (in this case {file_copies}), for backward compatibility.
author Patrick Mezard <pmezard@gmail.com>
date Sun, 13 Dec 2009 18:06:24 +0100
parents d3dbdca92458
children d6512b3e9ac0
line wrap: on
line diff
--- a/mercurial/templater.py	Sun Dec 13 18:06:24 2009 +0100
+++ b/mercurial/templater.py	Sun Dec 13 18:06:24 2009 +0100
@@ -77,8 +77,14 @@
             raise SyntaxError(_("error expanding '%s%%%s'") % (key, format))
         lm = map.copy()
         for i in v:
-            lm.update(i)
-            yield self.process(format, lm)
+            if isinstance(i, dict): 
+                lm.update(i)
+                yield self.process(format, lm)
+            else:
+                # v is not an iterable of dicts, this happen when 'key'
+                # has been fully expanded already and format is useless.
+                # If so, return the expanded value.
+                yield i
 
     def _filter(self, expr, get, map):
         if expr not in self.cache: