# HG changeset patch # User Alexis S. L. Carvalho # Date 1205824059 10800 # Node ID 653ddd1d7cd79654545c528b31b80ecf2aea7c83 # Parent 53cbb33e12698b61b0168757ae8c4c4b8f350d19 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. diff -r 53cbb33e1269 -r 653ddd1d7cd7 mercurial/commands.py --- 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) diff -r 53cbb33e1269 -r 653ddd1d7cd7 tests/test-merge-remove --- 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 + diff -r 53cbb33e1269 -r 653ddd1d7cd7 tests/test-merge-remove.out --- 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 diff -r 53cbb33e1269 -r 653ddd1d7cd7 tests/test-win32text --- 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 diff -r 53cbb33e1269 -r 653ddd1d7cd7 tests/test-win32text.out --- 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 # empty +% just linefeed +% just linefeed +no changes needed to linefeed +% just linefeed +M linefeed +reverting linefeed +% just linefeed