Mercurial > hg
comparison mercurial/merge.py @ 21082:0d67fccc0d43
merge: let manifestmerge emit 'keep' actions when keeping wd version
Such a 'keep' action will later be the preferred (non)action when there
is multiple ancestors. It is thus very convenient to have it explicitly.
The extra actions will only be emitted in the case where the local file has
changed since the ancestor but the other hasn't. That is the symmetrical
operation to a 'get' action.
This will create more action tuples that not really serve a purpose. The number
of actions will however have the number of changed files as upper bound and it
should thus not increase the memory/cpu use significantly.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Mon, 07 Apr 2014 02:12:28 +0200 |
parents | ffd7b6ce46ff |
children | f4014f646f71 |
comparison
equal
deleted
inserted
replaced
21081:ffd7b6ce46ff | 21082:0d67fccc0d43 |
---|---|
447 # Note: f as default is wrong - we can't really make a 3-way | 447 # Note: f as default is wrong - we can't really make a 3-way |
448 # merge without an ancestor file. | 448 # merge without an ancestor file. |
449 fla = ma.flags(fa) | 449 fla = ma.flags(fa) |
450 nol = 'l' not in fl1 + fl2 + fla | 450 nol = 'l' not in fl1 + fl2 + fla |
451 if n2 == a and fl2 == fla: | 451 if n2 == a and fl2 == fla: |
452 pass # remote unchanged - keep local | 452 actions.append((f, "k", (), "keep")) # remote unchanged |
453 elif n1 == a and fl1 == fla: # local unchanged - use remote | 453 elif n1 == a and fl1 == fla: # local unchanged - use remote |
454 if n1 == n2: # optimization: keep local content | 454 if n1 == n2: # optimization: keep local content |
455 actions.append((f, "e", (fl2,), "update permissions")) | 455 actions.append((f, "e", (fl2,), "update permissions")) |
456 else: | 456 else: |
457 actions.append((f, "g", (fl2,), "remote is newer")) | 457 actions.append((f, "g", (fl2,), "remote is newer")) |
632 if os.path.lexists(repo.wjoin(f)): | 632 if os.path.lexists(repo.wjoin(f)): |
633 repo.ui.debug("removing %s\n" % f) | 633 repo.ui.debug("removing %s\n" % f) |
634 audit(f) | 634 audit(f) |
635 util.unlinkpath(repo.wjoin(f)) | 635 util.unlinkpath(repo.wjoin(f)) |
636 | 636 |
637 numupdates = len(actions) | 637 numupdates = len([a for a in actions if a[1] != 'k']) |
638 workeractions = [a for a in actions if a[1] in 'gr'] | 638 workeractions = [a for a in actions if a[1] in 'gr'] |
639 updateactions = [a for a in workeractions if a[1] == 'g'] | 639 updateactions = [a for a in workeractions if a[1] == 'g'] |
640 updated = len(updateactions) | 640 updated = len(updateactions) |
641 removeactions = [a for a in workeractions if a[1] == 'r'] | 641 removeactions = [a for a in workeractions if a[1] == 'r'] |
642 removed = len(removeactions) | 642 removed = len(removeactions) |
643 actions = [a for a in actions if a[1] not in 'gr'] | 643 actions = [a for a in actions if a[1] not in 'grk'] |
644 | 644 |
645 hgsub = [a[1] for a in workeractions if a[0] == '.hgsubstate'] | 645 hgsub = [a[1] for a in workeractions if a[0] == '.hgsubstate'] |
646 if hgsub and hgsub[0] == 'r': | 646 if hgsub and hgsub[0] == 'r': |
647 subrepo.submerge(repo, wctx, mctx, wctx, overwrite) | 647 subrepo.submerge(repo, wctx, mctx, wctx, overwrite) |
648 | 648 |
776 repo.dirstate.add(f) | 776 repo.dirstate.add(f) |
777 elif m == "f": # forget | 777 elif m == "f": # forget |
778 repo.dirstate.drop(f) | 778 repo.dirstate.drop(f) |
779 elif m == "e": # exec change | 779 elif m == "e": # exec change |
780 repo.dirstate.normallookup(f) | 780 repo.dirstate.normallookup(f) |
781 elif m == "k": # keep | |
782 pass | |
781 elif m == "g": # get | 783 elif m == "g": # get |
782 if branchmerge: | 784 if branchmerge: |
783 repo.dirstate.otherparent(f) | 785 repo.dirstate.otherparent(f) |
784 else: | 786 else: |
785 repo.dirstate.normal(f) | 787 repo.dirstate.normal(f) |