Mercurial > public > mercurial-scm > hg
comparison mercurial/merge.py @ 20945:18adc15635a1
merge: keep destination filename as key in filemerge actions
Gives more readable debug output and makes it possible to compare/merge actions
later.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Sun, 02 Mar 2014 18:52:16 +0100 |
parents | 5b8d5803d7b7 |
children | 7731a2281cf0 |
comparison
equal
deleted
inserted
replaced
20944:5b8d5803d7b7 | 20945:18adc15635a1 |
---|---|
340 pmmf.add(f) | 340 pmmf.add(f) |
341 def renamegetop(f, args): | 341 def renamegetop(f, args): |
342 f2, flags = args | 342 f2, flags = args |
343 pmmf.add(f) | 343 pmmf.add(f) |
344 def mergeop(f, args): | 344 def mergeop(f, args): |
345 f2, fa, fd, move, anc = args | 345 f1, f2, fa, move, anc = args |
346 if move: | 346 if move: |
347 pmmf.discard(f) | 347 pmmf.discard(f1) |
348 pmmf.add(fd) | 348 pmmf.add(f) |
349 | 349 |
350 opmap = { | 350 opmap = { |
351 "a": addop, | 351 "a": addop, |
352 "dm": renamemoveop, | 352 "dm": renamemoveop, |
353 "dg": renamegetop, | 353 "dg": renamegetop, |
469 elif nol and n2 == a: # remote only changed 'x' | 469 elif nol and n2 == a: # remote only changed 'x' |
470 actions.append((f, "e", (fl2,), "update permissions")) | 470 actions.append((f, "e", (fl2,), "update permissions")) |
471 elif nol and n1 == a: # local only changed 'x' | 471 elif nol and n1 == a: # local only changed 'x' |
472 actions.append((f, "g", (fl1,), "remote is newer")) | 472 actions.append((f, "g", (fl1,), "remote is newer")) |
473 else: # both changed something | 473 else: # both changed something |
474 actions.append((f, "m", (f, fa, f, False, pa.node()), | 474 actions.append((f, "m", (f, f, fa, False, pa.node()), |
475 "versions differ")) | 475 "versions differ")) |
476 elif f in copied: # files we'll deal with on m2 side | 476 elif f in copied: # files we'll deal with on m2 side |
477 pass | 477 pass |
478 elif n1 and f in movewithdir: # directory rename, move local | 478 elif n1 and f in movewithdir: # directory rename, move local |
479 f2 = movewithdir[f] | 479 f2 = movewithdir[f] |
480 actions.append((f2, "dm", (f, fl1), | 480 actions.append((f2, "dm", (f, fl1), |
481 "remote directory rename - move from " + f)) | 481 "remote directory rename - move from " + f)) |
482 elif n1 and f in copy: | 482 elif n1 and f in copy: |
483 f2 = copy[f] | 483 f2 = copy[f] |
484 actions.append((f, "m", (f2, f2, f, False, pa.node()), | 484 actions.append((f, "m", (f, f2, f2, False, pa.node()), |
485 "local copied/moved to " + f2)) | 485 "local copied/moved from " + f2)) |
486 elif n1 and f in ma: # clean, a different, no remote | 486 elif n1 and f in ma: # clean, a different, no remote |
487 if n1 != ma[f]: | 487 if n1 != ma[f]: |
488 if acceptremote: | 488 if acceptremote: |
489 actions.append((f, "r", None, "remote delete")) | 489 actions.append((f, "r", None, "remote delete")) |
490 else: | 490 else: |
498 actions.append((f2, "dg", (f, fl2), | 498 actions.append((f2, "dg", (f, fl2), |
499 "local directory rename - get from " + f)) | 499 "local directory rename - get from " + f)) |
500 elif n2 and f in copy: | 500 elif n2 and f in copy: |
501 f2 = copy[f] | 501 f2 = copy[f] |
502 if f2 in m2: | 502 if f2 in m2: |
503 actions.append((f2, "m", (f, f2, f, False, pa.node()), | 503 actions.append((f, "m", (f2, f, f2, False, pa.node()), |
504 "remote copied to " + f)) | 504 "remote copied from " + f2)) |
505 else: | 505 else: |
506 actions.append((f2, "m", (f, f2, f, True, pa.node()), | 506 actions.append((f, "m", (f2, f, f2, True, pa.node()), |
507 "remote moved to " + f)) | 507 "remote moved from " + f2)) |
508 elif n2 and f not in ma: | 508 elif n2 and f not in ma: |
509 # local unknown, remote created: the logic is described by the | 509 # local unknown, remote created: the logic is described by the |
510 # following table: | 510 # following table: |
511 # | 511 # |
512 # force branchmerge different | action | 512 # force branchmerge different | action |
619 # prescan for merges | 619 # prescan for merges |
620 for a in actions: | 620 for a in actions: |
621 f, m, args, msg = a | 621 f, m, args, msg = a |
622 repo.ui.debug(" %s: %s -> %s\n" % (f, msg, m)) | 622 repo.ui.debug(" %s: %s -> %s\n" % (f, msg, m)) |
623 if m == "m": # merge | 623 if m == "m": # merge |
624 f2, fa, fd, move, anc = args | 624 f1, f2, fa, move, anc = args |
625 if fd == '.hgsubstate': # merged internally | 625 if f == '.hgsubstate': # merged internally |
626 continue | 626 continue |
627 repo.ui.debug(" preserving %s for resolve of %s\n" % (f, fd)) | 627 repo.ui.debug(" preserving %s for resolve of %s\n" % (f1, f)) |
628 fcl = wctx[f] | 628 fcl = wctx[f1] |
629 fco = mctx[f2] | 629 fco = mctx[f2] |
630 actx = repo[anc] | 630 actx = repo[anc] |
631 if fa in actx: | 631 if fa in actx: |
632 fca = actx[fa] | 632 fca = actx[fa] |
633 else: | 633 else: |
634 fca = repo.filectx(f, fileid=nullrev) | 634 fca = repo.filectx(f1, fileid=nullrev) |
635 ms.add(fcl, fco, fca, fd) | 635 ms.add(fcl, fco, fca, f) |
636 if f != fd and move: | 636 if f1 != f and move: |
637 moves.append(f) | 637 moves.append(f1) |
638 | 638 |
639 audit = repo.wopener.audit | 639 audit = repo.wopener.audit |
640 | 640 |
641 # remove renamed files after safely stored | 641 # remove renamed files after safely stored |
642 for f in moves: | 642 for f in moves: |
680 | 680 |
681 for i, a in enumerate(actions): | 681 for i, a in enumerate(actions): |
682 f, m, args, msg = a | 682 f, m, args, msg = a |
683 progress(_updating, z + i + 1, item=f, total=numupdates, unit=_files) | 683 progress(_updating, z + i + 1, item=f, total=numupdates, unit=_files) |
684 if m == "m": # merge | 684 if m == "m": # merge |
685 f2, fa, fd, move, anc = args | 685 f1, f2, fa, move, anc = args |
686 if fd == '.hgsubstate': # subrepo states need updating | 686 if f == '.hgsubstate': # subrepo states need updating |
687 subrepo.submerge(repo, wctx, mctx, wctx.ancestor(mctx), | 687 subrepo.submerge(repo, wctx, mctx, wctx.ancestor(mctx), |
688 overwrite) | 688 overwrite) |
689 continue | 689 continue |
690 audit(fd) | 690 audit(f) |
691 r = ms.resolve(fd, wctx) | 691 r = ms.resolve(f, wctx) |
692 if r is not None and r > 0: | 692 if r is not None and r > 0: |
693 unresolved += 1 | 693 unresolved += 1 |
694 else: | 694 else: |
695 if r is None: | 695 if r is None: |
696 updated += 1 | 696 updated += 1 |
791 if branchmerge: | 791 if branchmerge: |
792 repo.dirstate.otherparent(f) | 792 repo.dirstate.otherparent(f) |
793 else: | 793 else: |
794 repo.dirstate.normal(f) | 794 repo.dirstate.normal(f) |
795 elif m == "m": # merge | 795 elif m == "m": # merge |
796 f2, fa, fd, move, anc = args | 796 f1, f2, fa, move, anc = args |
797 if branchmerge: | 797 if branchmerge: |
798 # We've done a branch merge, mark this file as merged | 798 # We've done a branch merge, mark this file as merged |
799 # so that we properly record the merger later | 799 # so that we properly record the merger later |
800 repo.dirstate.merge(fd) | 800 repo.dirstate.merge(f) |
801 if f != f2: # copy/rename | 801 if f1 != f2: # copy/rename |
802 if move: | 802 if move: |
803 repo.dirstate.remove(f) | 803 repo.dirstate.remove(f1) |
804 if f != fd: | 804 if f1 != f: |
805 repo.dirstate.copy(f, fd) | 805 repo.dirstate.copy(f1, f) |
806 else: | 806 else: |
807 repo.dirstate.copy(f2, fd) | 807 repo.dirstate.copy(f2, f) |
808 else: | 808 else: |
809 # We've update-merged a locally modified file, so | 809 # We've update-merged a locally modified file, so |
810 # we set the dirstate to emulate a normal checkout | 810 # we set the dirstate to emulate a normal checkout |
811 # of that file some time in the past. Thus our | 811 # of that file some time in the past. Thus our |
812 # merge will appear as a normal local file | 812 # merge will appear as a normal local file |
813 # modification. | 813 # modification. |
814 if f2 == fd: # file not locally copied/moved | 814 if f2 == f: # file not locally copied/moved |
815 repo.dirstate.normallookup(fd) | 815 repo.dirstate.normallookup(f) |
816 if move: | 816 if move: |
817 repo.dirstate.drop(f) | 817 repo.dirstate.drop(f1) |
818 elif m == "dm": # directory rename, move local | 818 elif m == "dm": # directory rename, move local |
819 f0, flag = args | 819 f0, flag = args |
820 if f0 not in repo.dirstate: | 820 if f0 not in repo.dirstate: |
821 # untracked file moved | 821 # untracked file moved |
822 continue | 822 continue |