diff mercurial/cmdutil.py @ 4351:051fb8c2567c

command line templates: add formatnode filter This will print a full hash node with --debug and a short one otherwise. Use it with some default templates and in map-cmdline.default to print the parents. This should fix issue538.
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Mon, 16 Apr 2007 13:00:23 -0300
parents 3380eb6d7c32
children 1ccd3b9a7b1f
line wrap: on
line diff
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -325,10 +325,14 @@ class changeset_templater(changeset_prin
 
     def __init__(self, ui, repo, patch, brinfo, mapfile, buffered):
         changeset_printer.__init__(self, ui, repo, patch, brinfo, buffered)
-        self.t = templater.templater(mapfile, templater.common_filters,
-                                     cache={'parent': '{rev}:{node|short} ',
-                                            'manifest': '{rev}:{node|short}',
-                                            'filecopy': '{name} ({source})'})
+        filters = templater.common_filters.copy()
+        filters['formatnode'] = (ui.debugflag and (lambda x: x)
+                                 or (lambda x: x[:12]))
+        self.t = templater.templater(mapfile, filters,
+                                     cache={
+                                         'parent': '{rev}:{node|formatnode} ',
+                                         'manifest': '{rev}:{node|formatnode}',
+                                         'filecopy': '{name} ({source})'})
 
     def use_template(self, t):
         '''set template string to use'''