merge: fix handling of deleted files
authorAlexis S. L. Carvalho <alexis@cecm.usp.br>
Wed, 12 Mar 2008 15:44:08 -0700
changeset 6242 a375ffc2aa1b
parent 6241 a718e66836e8
child 6243 437eef39458d
child 6247 7f4257b5cbfc
merge: fix handling of deleted files
mercurial/merge.py
--- a/mercurial/merge.py	Wed Mar 12 15:33:43 2008 -0700
+++ b/mercurial/merge.py	Wed Mar 12 15:44:08 2008 -0700
@@ -29,7 +29,7 @@
                              % (fn, folded[fold]))
         folded[fold] = fn
 
-def forgetremoved(wctx, mctx):
+def forgetremoved(wctx, mctx, branchmerge):
     """
     Forget removed files
 
@@ -38,13 +38,23 @@
     then we need to remove it from the dirstate, to prevent the
     dirstate from listing the file when it is no longer in the
     manifest.
+
+    If we're merging, and the other revision has removed a file
+    that is not present in the working directory, we need to mark it
+    as removed.
     """
 
     action = []
     man = mctx.manifest()
-    for f in wctx.deleted() + wctx.removed():
+    state = branchmerge and 'r' or 'f'
+    for f in wctx.deleted():
         if f not in man:
-            action.append((f, "f"))
+            action.append((f, state))
+
+    if not branchmerge:
+        for f in wctx.removed():
+            if f not in man:
+                action.append((f, "f"))
 
     return action
 
@@ -608,8 +618,7 @@
             checkunknown(wc, p2)
         if not util.checkfolding(repo.path):
             checkcollision(p2)
-        if not branchmerge:
-            action += forgetremoved(wc, p2)
+        action += forgetremoved(wc, p2, branchmerge)
         action += manifestmerge(repo, wc, p2, pa, overwrite, partial)
 
         ### apply phase