make templater bit more flexible and efficient for external users.
authorVadim Gelfer <vadim.gelfer@gmail.com>
Wed, 03 May 2006 14:35:17 -0700
changeset 2191 c2e43535d4d1
parent 2190 b67fcd91dd1b
child 2192 2be3ac7abc21
make templater bit more flexible and efficient for external users.
mercurial/templater.py
--- a/mercurial/templater.py	Wed May 03 11:00:24 2006 -0700
+++ b/mercurial/templater.py	Wed May 03 14:35:17 2006 -0700
@@ -268,6 +268,7 @@
 
 common_filters = {
     "addbreaks": nl2br,
+    "basename": os.path.basename,
     "age": age,
     "date": lambda x: util.datestr(x),
     "domain": domain,
@@ -336,15 +337,16 @@
     def write_header(self, thing):
         self.write(thing, header=True)
 
-    def show(self, rev=0, changenode=None, brinfo=None):
+    def show(self, rev=0, changenode=None, brinfo=None, changes=None,
+             **props):
         '''show a single changeset or file revision'''
         log = self.repo.changelog
         if changenode is None:
             changenode = log.node(rev)
         elif not rev:
             rev = log.rev(changenode)
-
-        changes = log.read(changenode)
+        if changes is None:
+            changes = log.read(changenode)
 
         def showlist(name, values, plural=None, **args):
             '''expand set of values.
@@ -453,7 +455,7 @@
             showadds = ''
             showdels = ''
 
-        props = {
+        defprops = {
             'author': changes[1],
             'branches': showbranches,
             'date': changes[2],
@@ -467,6 +469,8 @@
             'rev': rev,
             'tags': showtags,
             }
+        props = props.copy()
+        props.update(defprops)
 
         try:
             if self.ui.debugflag and 'header_debug' in self.t: