Mercurial > public > mercurial-scm > hg-stable
comparison 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 |
comparison
equal
deleted
inserted
replaced
21388:9a1e3d705c2c | 21389:e741972017d9 |
---|---|
569 else: | 569 else: |
570 _checkcollision(repo, m1, actions) | 570 _checkcollision(repo, m1, actions) |
571 | 571 |
572 return actions | 572 return actions |
573 | 573 |
574 actionpriority = dict((m, p) for p, m in enumerate( | |
575 ['r', 'f', 'g', 'a', 'k', 'm', 'dm', 'dg', 'dr', 'cd', 'dc', 'rd', 'e'])) | |
576 | |
574 def actionkey(a): | 577 def actionkey(a): |
575 return a[1] in "rf" and -1 or 0, a | 578 return actionpriority[a[1]], a |
576 | 579 |
577 def getremove(repo, mctx, overwrite, args): | 580 def getremove(repo, mctx, overwrite, args): |
578 """apply usually-non-interactive updates to the working directory | 581 """apply usually-non-interactive updates to the working directory |
579 | 582 |
580 mctx is the context to be merged into the working copy | 583 mctx is the context to be merged into the working copy |
846 def recordupdates(repo, actions, branchmerge): | 849 def recordupdates(repo, actions, branchmerge): |
847 "record merge actions to the dirstate" | 850 "record merge actions to the dirstate" |
848 | 851 |
849 for a in actions: | 852 for a in actions: |
850 f, m, args, msg = a | 853 f, m, args, msg = a |
851 if m == "r": # remove | 854 if m == "r": # remove (must come first) |
852 if branchmerge: | 855 if branchmerge: |
853 repo.dirstate.remove(f) | 856 repo.dirstate.remove(f) |
854 else: | 857 else: |
855 repo.dirstate.drop(f) | 858 repo.dirstate.drop(f) |
859 elif m == "f": # forget (must come first) | |
860 repo.dirstate.drop(f) | |
856 elif m == "a": # re-add | 861 elif m == "a": # re-add |
857 if not branchmerge: | 862 if not branchmerge: |
858 repo.dirstate.add(f) | 863 repo.dirstate.add(f) |
859 elif m == "f": # forget | |
860 repo.dirstate.drop(f) | |
861 elif m == "e": # exec change | 864 elif m == "e": # exec change |
862 repo.dirstate.normallookup(f) | 865 repo.dirstate.normallookup(f) |
863 elif m == "k": # keep | 866 elif m == "k": # keep |
864 pass | 867 pass |
865 elif m == "g": # get | 868 elif m == "g": # get |