keyword: disable expansion for annotate
authorChristian Ebert <blacktrash@gmx.net>
Thu, 12 Jun 2008 11:10:04 +0200
changeset 461 2275041e7deb
parent 460 d9aae4cd69be
child 476 0c36b6c991f9
keyword: disable expansion for annotate Keyword expansion should not be annotated. Annotate revision when unexpanded keyword was inserted. Add test.
hgkw/keyword.py
tests/test-keyword
tests/test-keyword.out
--- a/hgkw/keyword.py	Thu Jun 12 02:35:38 2008 +0200
+++ b/hgkw/keyword.py	Thu Jun 12 11:10:04 2008 +0200
@@ -90,7 +90,7 @@
 commands.optionalrepo += ' kwdemo'
 
 # hg commands that do not act on keywords
-nokwcommands = ('add addremove bundle copy export grep incoming init'
+nokwcommands = ('add addremove annotate bundle copy export grep incoming init'
                 ' log outgoing push rename rollback tip'
                 ' convert email glog')
 
@@ -517,6 +517,11 @@
             kwt.restrict = True
         patch_diff(repo, node1, node2, match, fp, changes, opts)
 
+    def kwweb_annotate(web, req, tmpl):
+        '''Wraps webcommands.annotate turning off keyword expansion.'''
+        kwt.matcher = util.never
+        return webcommands_annotate(web, req, tmpl)
+
     def kwweb_changeset(web, req, tmpl):
         '''Wraps webcommands.changeset turning off keyword expansion.'''
         kwt.matcher = util.never
@@ -531,11 +536,13 @@
 
     patchfile_init = patch.patchfile.__init__
     patch_diff = patch.diff
+    webcommands_annotate = webcommands.annotate
     webcommands_changeset = webcommands.changeset
     webcommands_filediff = webcommands.filediff
 
     patch.patchfile.__init__ = kwpatchfile_init
     patch.diff = kw_diff
+    webcommands.annotate = kwweb_annotate
     webcommands.changeset = webcommands.rev = kwweb_changeset
     webcommands.filediff = webcommands.diff = kwweb_filediff
 
--- a/tests/test-keyword	Thu Jun 12 02:35:38 2008 +0200
+++ b/tests/test-keyword	Thu Jun 12 11:10:04 2008 +0200
@@ -214,6 +214,8 @@
 echo % hg cat
 hg cat sym a b
 echo
+echo % annotate
+hg annotate a
 
 echo % remove
 hg debugrebuildstate
--- a/tests/test-keyword.out	Thu Jun 12 02:35:38 2008 +0200
+++ b/tests/test-keyword.out	Thu Jun 12 11:10:04 2008 +0200
@@ -294,6 +294,11 @@
 $Xinfo: User Name <user@example.com>: firstline $
 ignore $Id$
 a
+% annotate
+1: expand $Id$
+1: do not process $Id:
+1: xxx $
+2: $Xinfo$
 % remove
 % status
 % rollback