changeset 6299:653ddd1d7cd7

revert: update state of files in the "checkout" list This can make a difference when there are filters involved and decode(encode(working-dir-data)) != working-dir-data even though encode(decode(repo-data)) == repo-data An example is a working dir file that uses only \n when you're using the win32text extension.
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Tue, 18 Mar 2008 04:07:39 -0300
parents 53cbb33e1269
children 874ca958025b
files mercurial/commands.py tests/test-merge-remove tests/test-merge-remove.out tests/test-win32text tests/test-win32text.out
diffstat 5 files changed, 51 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Tue Mar 18 04:07:39 2008 -0300
+++ b/mercurial/commands.py	Tue Mar 18 04:07:39 2008 -0300
@@ -2380,8 +2380,19 @@
                     pass
                 repo.dirstate.remove(f)
 
+            normal = None
+            if node == parent:
+                # We're reverting to our parent. If possible, we'd like status
+                # to report the file as clean. We have to use normallookup for
+                # merges to avoid losing information about merged/dirty files.
+                if p2 != nullid:
+                    normal = repo.dirstate.normallookup
+                else:
+                    normal = repo.dirstate.normal
             for f in revert[0]:
                 checkout(f)
+                if normal:
+                    normal(f)
 
             for f in add[0]:
                 checkout(f)
--- a/tests/test-merge-remove	Tue Mar 18 04:07:39 2008 -0300
+++ b/tests/test-merge-remove	Tue Mar 18 04:07:39 2008 -0300
@@ -34,3 +34,10 @@
 hg add -v foo1 bar
 hg debugstate --nodates
 hg st -qC
+
+echo '% reverting foo1 and bar'
+hg revert -vr . foo1 bar
+hg debugstate --nodates
+hg st -qC
+hg diff
+
--- a/tests/test-merge-remove.out	Tue Mar 18 04:07:39 2008 -0300
+++ b/tests/test-merge-remove.out	Tue Mar 18 04:07:39 2008 -0300
@@ -22,3 +22,15 @@
 M bar
 M foo1
   foo
+% reverting foo1 and bar
+warning: working directory has two parents, tag '.' uses the first
+saving current version of bar as bar.orig
+reverting bar
+saving current version of foo1 as foo1.orig
+reverting foo1
+n   0         -2 bar
+m 644         14 foo1
+copy: foo -> foo1
+M bar
+M foo1
+  foo
--- a/tests/test-win32text	Tue Mar 18 04:07:39 2008 -0300
+++ b/tests/test-win32text	Tue Mar 18 04:07:39 2008 -0300
@@ -99,3 +99,17 @@
 hg ci -m 7 -d'0 0'
 python print.py < f5.sh
 hg cat f5.sh | python print.py
+
+echo '% just linefeed' > linefeed
+hg ci -qAm 8 linefeed
+python print.py < linefeed
+hg cat linefeed | python print.py
+hg st -q
+hg revert -a linefeed
+python print.py < linefeed
+hg st -q
+echo modified >> linefeed
+hg st -q
+hg revert -a
+hg st -q
+python print.py < linefeed
--- a/tests/test-win32text.out	Tue Mar 18 04:07:39 2008 -0300
+++ b/tests/test-win32text.out	Tue Mar 18 04:07:39 2008 -0300
@@ -177,3 +177,10 @@
 
 # empty<CR><LF>
 # empty<LF>
+% just linefeed<LF>
+% just linefeed<LF>
+no changes needed to linefeed
+% just linefeed<LF>
+M linefeed
+reverting linefeed
+% just linefeed<CR><LF>