changeset 2191:c2e43535d4d1

make templater bit more flexible and efficient for external users.
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Wed, 03 May 2006 14:35:17 -0700
parents b67fcd91dd1b
children 2be3ac7abc21
files mercurial/templater.py
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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: