normallookup: during merges, restore the state saved by remove
authorAlexis S. L. Carvalho <alexis@cecm.usp.br>
Tue, 18 Mar 2008 04:07:39 -0300
changeset 6298 53cbb33e1269
parent 6297 fed1a9c22076
child 6299 653ddd1d7cd7
normallookup: during merges, restore the state saved by remove
mercurial/dirstate.py
tests/test-confused-revert.out
tests/test-merge-remove
tests/test-merge-remove.out
--- a/mercurial/dirstate.py	Tue Mar 18 04:07:39 2008 -0300
+++ b/mercurial/dirstate.py	Tue Mar 18 04:07:39 2008 -0300
@@ -244,6 +244,21 @@
 
     def normallookup(self, f):
         'mark a file normal, but possibly dirty'
+        if self._pl[1] != nullid and f in self._map:
+            # if there is a merge going on and the file was either
+            # in state 'm' or dirty before being removed, restore that state.
+            entry = self._map[f]
+            if entry[0] == 'r' and entry[2] in (-1, -2):
+                source = self._copymap.get(f)
+                if entry[2] == -1:
+                    self.merge(f)
+                elif entry[2] == -2:
+                    self.normaldirty(f)
+                if source:
+                    self.copy(source, f)
+                return
+            if entry[0] == 'm' or entry[0] == 'n' and entry[2] == -2:
+                return
         self._dirty = True
         self._changepath(f, 'n', True)
         self._map[f] = ('n', 0, -1, -1, 0)
--- a/tests/test-confused-revert.out	Tue Mar 18 04:07:39 2008 -0300
+++ b/tests/test-confused-revert.out	Tue Mar 18 04:07:39 2008 -0300
@@ -22,6 +22,7 @@
 undeleting a
 forgetting b
 %%% should show b unknown and a marked modified (merged)
+M a
 ? b
 %%% should show foo-b
 foo-b
--- 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
@@ -27,3 +27,10 @@
 hg rm -f foo1 bar
 hg debugstate --nodates
 hg st -qC
+
+echo '% readding foo1 and bar'
+cp F foo1
+cp B bar
+hg add -v foo1 bar
+hg debugstate --nodates
+hg st -qC
--- 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
@@ -13,3 +13,12 @@
 R bar
 R foo1
   foo
+% readding foo1 and bar
+adding bar
+adding foo1
+n   0         -2 bar
+m 644         14 foo1
+copy: foo -> foo1
+M bar
+M foo1
+  foo