[PATCH 1 of 2] keyword: force dirstate normal when all changes in a file are recorded

Christian Ebert blacktrash at gmx.net
Mon May 31 20:45:20 CDT 2010


# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1275347145 -7200
# Node ID db572718038726200d93fae3a0c2a988c8fba78f
# Parent  ac6fec2af8c882670144d9cb8e3637d1cee1a171
keyword: force dirstate normal when all changes in a file are recorded

Before this bugfix a file whose changes were entirely recorded was still
considered modified by "hg status".

Note: the test must use hg record -l/--logfile, because this is not
reproducible with hg record -m/--message.

diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -220,6 +220,8 @@
                     self.repo.wwrite(f, data, mf.flags(f))
                     if node is None:
                         self.repo.dirstate.normal(f)
+                    elif self.record:
+                        self.repo.dirstate.normallookup(f)
             self.restrict = False
 
     def shrinktext(self, text):
diff --git a/tests/test-keyword b/tests/test-keyword
--- a/tests/test-keyword
+++ b/tests/test-keyword
@@ -142,7 +142,7 @@
 echo % compare changenodes in a c
 cat a c
 
-echo % record
+echo % record chunk
 python -c \
 'l=open("a").readlines();l.insert(1,"foo\n");l.append("bar\n");open("a","w").writelines(l);'
 hg record -d '1 10' -m rectest<<EOF
@@ -157,6 +157,19 @@
 cat a
 hg diff | grep -v 'b/a'
 hg rollback
+
+echo % record file
+echo foo > msg
+# do not use "hg record -m" here!
+hg record -l msg -d '1 11'<<EOF
+y
+y
+y
+EOF
+echo % a should be clean
+hg status -A a
+rm msg
+hg rollback
 hg update -C
 
 echo % init --mq
diff --git a/tests/test-keyword.out b/tests/test-keyword.out
--- a/tests/test-keyword.out
+++ b/tests/test-keyword.out
@@ -132,7 +132,7 @@
 xxx $
 $Id: c,v 40a904bbbe4c 1970/01/01 00:00:01 user $
 tests for different changenodes
-% record
+% record chunk
 diff --git a/a b/a
 2 hunks, 2 lines changed
 examine changes to 'a'? [Ynsfdaq?] 
@@ -164,6 +164,24 @@
  xxx $
 +bar
 rolling back to revision 2 (undo commit)
+% record file
+diff --git a/a b/a
+2 hunks, 2 lines changed
+examine changes to 'a'? [Ynsfdaq?] 
+@@ -1,3 +1,4 @@
+ expand $Id$
++foo
+ do not process $Id:
+ xxx $
+record change 1/2 to 'a'? [Ynsfdaq?] 
+@@ -2,2 +3,3 @@
+ do not process $Id:
+ xxx $
++bar
+record change 2/2 to 'a'? [Ynsfdaq?] 
+% a should be clean
+C a
+rolling back to revision 2 (undo commit)
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 % init --mq
 % qimport


More information about the Mercurial-devel mailing list