diff mercurial/merge.py @ 21389:e741972017d9

merge: change priority / ordering of merge actions The ordering of actions matters. Normal file system semantics is that files have to be removed before a directory with the same name can be created. Before the first ordering key was to have 'r' and 'f' actions come first, secondary key was the filename. Because of future refactorings we want to consistently have all action types (with a sensible priority) as separate first keys. Grouped by action type, we sort by filename. Not processing in strict filename order could give worse performance, especially on spinning disks. That is however primarily an issue in the cases where "all" actions are of the same kind and will be grouped together anyway.
author Mads Kiilerich <madski@unity3d.com>
date Fri, 02 May 2014 01:09:14 +0200
parents fa601c4e03f9
children 26b84128c54d
line wrap: on
line diff
--- a/mercurial/merge.py	Sat May 17 00:47:42 2014 -0700
+++ b/mercurial/merge.py	Fri May 02 01:09:14 2014 +0200
@@ -571,8 +571,11 @@
 
     return actions
 
+actionpriority = dict((m, p) for p, m in enumerate(
+    ['r', 'f', 'g', 'a', 'k', 'm', 'dm', 'dg', 'dr', 'cd', 'dc', 'rd', 'e']))
+
 def actionkey(a):
-    return a[1] in "rf" and -1 or 0, a
+    return actionpriority[a[1]], a
 
 def getremove(repo, mctx, overwrite, args):
     """apply usually-non-interactive updates to the working directory
@@ -848,16 +851,16 @@
 
     for a in actions:
         f, m, args, msg = a
-        if m == "r": # remove
+        if m == "r": # remove (must come first)
             if branchmerge:
                 repo.dirstate.remove(f)
             else:
                 repo.dirstate.drop(f)
+        elif m == "f": # forget (must come first)
+            repo.dirstate.drop(f)
         elif m == "a": # re-add
             if not branchmerge:
                 repo.dirstate.add(f)
-        elif m == "f": # forget
-            repo.dirstate.drop(f)
         elif m == "e": # exec change
             repo.dirstate.normallookup(f)
         elif m == "k": # keep