[PATCH 5 of 6] merge: reuse 'r' action code for 'rm' actions in recordupdates()

Martin von Zweigbergk martinvonz at google.com
Wed Dec 3 11:17:15 CST 2014


# HG changeset patch
# User Martin von Zweigbergk <martinvonz at google.com>
# Date 1416814310 28800
#      Sun Nov 23 23:31:50 2014 -0800
# Node ID 79d509ee6a41ef5903bf78cc75d9cd0e5213807d
# Parent  4491dd19d9566ad6b64ddb50312b1e6d57a24e27
merge: reuse 'r' action code for 'rm' actions in recordupdates()

The 'r' and 'rm' actions behave the same in recordupdates(), and the
'm' (merge) action has already caused the move source to be stored
away, so we can safely remove the file a little earlier (where 'r'
actions are being acted upon).

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -852,11 +852,12 @@
 def recordupdates(repo, actions, branchmerge):
     "record merge actions to the dirstate"
     # remove (must come first)
-    for f, args, msg in actions['r']:
-        if branchmerge:
-            repo.dirstate.remove(f)
-        else:
-            repo.dirstate.drop(f)
+    for m in 'r', 'rm':
+        for f, args, msg in actions[m]:
+            if branchmerge:
+                repo.dirstate.remove(f)
+            else:
+                repo.dirstate.drop(f)
 
     # forget (must come first)
     for f, args, msg in actions['f']:
@@ -903,13 +904,6 @@
             if f2 == f: # file not locally copied/moved
                 repo.dirstate.normallookup(f)
 
-    # remove file that moved away
-    for f, args, msg in actions['rm']:
-        if branchmerge:
-            repo.dirstate.remove(f)
-        else:
-            repo.dirstate.drop(f)
-
     # directory rename, move local
     for f, args, msg in actions['dm']:
         f0, flag = args


More information about the Mercurial-devel mailing list