hgkw/keyword.py
changeset 341 5ef2b11df3d3
parent 340 9e9f6cbcf20b
child 344 1346cc5a6461
--- a/hgkw/keyword.py	Tue Jan 15 13:19:23 2008 +0100
+++ b/hgkw/keyword.py	Wed Jan 16 11:22:16 2008 +0100
@@ -96,7 +96,8 @@
     '''Returns True if cmd should trigger restricted expansion.
     Keywords will only expanded when writing to working dir.
     Crucial for mq as expanded keywords should not make it into patches.'''
-    return cmd in ('qimport', 'qnew', 'qpush', 'qrefresh', 'record', 'qrecord')
+    return cmd in ('diff1', 
+                   'qimport', 'qnew', 'qpush', 'qrefresh', 'record', 'qrecord')
 
 
 _kwtemplater = None
@@ -421,6 +422,15 @@
     if hgcmd in nokwcommands:
         return
 
+    if hgcmd == 'diff':
+        # only expand if comparing against working dir
+        node1, node2 = cmdutil.revpair(repo, cmdopts.get('rev'))
+        if node2 is not None:
+            return
+        # shrink if rev is not current node
+        if node1 is not None and node1 != repo.changectx().node():
+            hgcmd = 'diff1'
+
     inc, exc = [], ['.hgtags']
     for pat, opt in ui.configitems('keyword'):
         if opt != 'ignore':