(0.9.2compat) do not bother about debug templates 0.9.2compat
authorChristian Ebert <blacktrash@gmx.net>
Mon, 26 Nov 2007 12:52:54 +0100
branch0.9.2compat
changeset 303 46ccec2f325f
parent 299 50bb27cfd926
child 311 6160401f94f2
(0.9.2compat) do not bother about debug templates
hgkw/keyword.py
tests/test-keyword
tests/test-keyword.out
--- a/hgkw/keyword.py	Wed Nov 14 13:36:41 2007 +0100
+++ b/hgkw/keyword.py	Mon Nov 26 12:52:54 2007 +0100
@@ -168,7 +168,6 @@
         self.t = expand or None
         self.path = path
         self.node = node
-        self.debug = self.ui.debugflag
 
         kwmaps = self.ui.configitems('keywordmaps')
         if kwmaps: # override default templates
@@ -210,26 +209,22 @@
         except AttributeError:
             self.repo.dirstate.update(files, 'n')
 
-    def kwsub(self, mobj):
-        '''Substitutes keyword using corresponding template.'''
-        kw = mobj.group(1)
-        self.t.use_template(self.templates[kw])
-        self.ui.pushbuffer()
-        self.t.show(changenode=self.node, root=self.repo.root, file=self.path)
-        keywordsub = templater.firstline(self.ui.popbuffer())
-        return '$%s: %s $' % (kw, keywordsub)
-
     def substitute(self, node, data, subfunc):
-        '''Obtains node if missing.
-        Ensures consistent templates regardless of ui.debugflag.
-        Calls given substitution function.'''
+        '''Obtains node if missing, and calls given substitution function.'''
         if not self.node:
             c = context.filectx(self.repo, self.path, fileid=node)
             self.node = c.node()
-        self.ui.debugflag = False
-        result = subfunc(self.kwsub, data)
-        self.ui.debugflag = self.debug
-        return result
+
+        def kwsub(mobj):
+            '''Substitutes keyword using corresponding template.'''
+            kw = mobj.group(1)
+            self.t.use_template(self.templates[kw])
+            self.ui.pushbuffer()
+            self.t.show(changenode=self.node,
+                        root=self.repo.root, file=self.path)
+            return '$%s: %s $' % (kw, templater.firstline(self.ui.popbuffer()))
+
+        return subfunc(kwsub, data)
 
     def expand(self, node, data):
         '''Returns data with keywords expanded.'''
--- a/tests/test-keyword	Wed Nov 14 13:36:41 2007 +0100
+++ b/tests/test-keyword	Mon Nov 26 12:52:54 2007 +0100
@@ -22,9 +22,6 @@
 
 hg --quiet kwdemo "Branch = {branches}"
 
-echo % do not expand debug templates
-hg --debug kwdemo "ADD = empty{file_adds}" | grep 'ADD'
-
 hg init Test
 cd Test
 
--- a/tests/test-keyword.out	Wed Nov 14 13:36:41 2007 +0100
+++ b/tests/test-keyword.out	Mon Nov 26 12:52:54 2007 +0100
@@ -65,10 +65,6 @@
 [keywordmaps]
 Branch = {branches}
 $Branch: demobranch $
-% do not expand debug templates
-ADD = empty{file_adds}
-$ADD$
-$ADD: empty $
 % kwshrink should exit silently in empty/invalid repo
 % cat
 expand $Id$