mercurial/dirstate.py
changeset 6298 53cbb33e1269
parent 6297 fed1a9c22076
child 6326 af3f26b6bba4
--- 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)