Mercurial > hg
comparison mercurial/merge.py @ 20897:0b50788c160c
merge: use ancestor filename from planning phase instead of filectx ancestor
test-merge-types.t changes a bit in flag merging. It relied on the
implementation detail that 100% identical revlog entries are reused. The revlog
reuse did that fctx.ancestor() saw an ancestor where there really not was one.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Tue, 25 Feb 2014 20:30:08 +0100 |
parents | 6500a2eebee8 |
children | 003cb972178d |
comparison
equal
deleted
inserted
replaced
20896:9fae01831dea | 20897:0b50788c160c |
---|---|
338 f2, fd, flags = args | 338 f2, fd, flags = args |
339 if f: | 339 if f: |
340 pmmf.discard(f) | 340 pmmf.discard(f) |
341 pmmf.add(fd) | 341 pmmf.add(fd) |
342 def mergeop(f, args): | 342 def mergeop(f, args): |
343 f2, fd, move = args | 343 f2, fa, fd, move = args |
344 if move: | 344 if move: |
345 pmmf.discard(f) | 345 pmmf.discard(f) |
346 pmmf.add(fd) | 346 pmmf.add(fd) |
347 | 347 |
348 opmap = { | 348 opmap = { |
466 elif nol and n2 == a: # remote only changed 'x' | 466 elif nol and n2 == a: # remote only changed 'x' |
467 actions.append((f, "e", (fl2,), "update permissions")) | 467 actions.append((f, "e", (fl2,), "update permissions")) |
468 elif nol and n1 == a: # local only changed 'x' | 468 elif nol and n1 == a: # local only changed 'x' |
469 actions.append((f, "g", (fl1,), "remote is newer")) | 469 actions.append((f, "g", (fl1,), "remote is newer")) |
470 else: # both changed something | 470 else: # both changed something |
471 actions.append((f, "m", (f, f, False), "versions differ")) | 471 actions.append((f, "m", (f, fa, f, False), "versions differ")) |
472 elif f in copied: # files we'll deal with on m2 side | 472 elif f in copied: # files we'll deal with on m2 side |
473 pass | 473 pass |
474 elif n1 and f in movewithdir: # directory rename | 474 elif n1 and f in movewithdir: # directory rename |
475 f2 = movewithdir[f] | 475 f2 = movewithdir[f] |
476 actions.append((f, "d", (None, f2, fl1), | 476 actions.append((f, "d", (None, f2, fl1), |
477 "remote renamed directory to " + f2)) | 477 "remote renamed directory to " + f2)) |
478 elif n1 and f in copy: | 478 elif n1 and f in copy: |
479 f2 = copy[f] | 479 f2 = copy[f] |
480 actions.append((f, "m", (f2, f, False), | 480 actions.append((f, "m", (f2, f2, f, False), |
481 "local copied/moved to " + f2)) | 481 "local copied/moved to " + f2)) |
482 elif n1 and f in ma: # clean, a different, no remote | 482 elif n1 and f in ma: # clean, a different, no remote |
483 if n1 != ma[f]: | 483 if n1 != ma[f]: |
484 if acceptremote: | 484 if acceptremote: |
485 actions.append((f, "r", None, "remote delete")) | 485 actions.append((f, "r", None, "remote delete")) |
494 actions.append((None, "d", (f, f2, fl2), | 494 actions.append((None, "d", (f, f2, fl2), |
495 "local renamed directory to " + f2)) | 495 "local renamed directory to " + f2)) |
496 elif n2 and f in copy: | 496 elif n2 and f in copy: |
497 f2 = copy[f] | 497 f2 = copy[f] |
498 if f2 in m2: | 498 if f2 in m2: |
499 actions.append((f2, "m", (f, f, False), | 499 actions.append((f2, "m", (f, f2, f, False), |
500 "remote copied to " + f)) | 500 "remote copied to " + f)) |
501 else: | 501 else: |
502 actions.append((f2, "m", (f, f, True), | 502 actions.append((f2, "m", (f, f2, f, True), |
503 "remote moved to " + f)) | 503 "remote moved to " + f)) |
504 elif n2 and f not in ma: | 504 elif n2 and f not in ma: |
505 # local unknown, remote created: the logic is described by the | 505 # local unknown, remote created: the logic is described by the |
506 # following table: | 506 # following table: |
507 # | 507 # |
517 if force and not branchmerge: | 517 if force and not branchmerge: |
518 actions.append((f, "g", (fl2,), "remote created")) | 518 actions.append((f, "g", (fl2,), "remote created")) |
519 else: | 519 else: |
520 different = _checkunknownfile(repo, wctx, p2, f) | 520 different = _checkunknownfile(repo, wctx, p2, f) |
521 if force and branchmerge and different: | 521 if force and branchmerge and different: |
522 actions.append((f, "m", (f, f, False), | 522 # FIXME: This is wrong - f is not in ma ... |
523 actions.append((f, "m", (f, f, f, False), | |
523 "remote differs from untracked local")) | 524 "remote differs from untracked local")) |
524 elif not force and different: | 525 elif not force and different: |
525 aborts.append((f, "ud")) | 526 aborts.append((f, "ud")) |
526 else: | 527 else: |
527 actions.append((f, "g", (fl2,), "remote created")) | 528 actions.append((f, "g", (fl2,), "remote created")) |
615 # prescan for merges | 616 # prescan for merges |
616 for a in actions: | 617 for a in actions: |
617 f, m, args, msg = a | 618 f, m, args, msg = a |
618 repo.ui.debug(" %s: %s -> %s\n" % (f, msg, m)) | 619 repo.ui.debug(" %s: %s -> %s\n" % (f, msg, m)) |
619 if m == "m": # merge | 620 if m == "m": # merge |
620 f2, fd, move = args | 621 f2, fa, fd, move = args |
621 if fd == '.hgsubstate': # merged internally | 622 if fd == '.hgsubstate': # merged internally |
622 continue | 623 continue |
623 repo.ui.debug(" preserving %s for resolve of %s\n" % (f, fd)) | 624 repo.ui.debug(" preserving %s for resolve of %s\n" % (f, fd)) |
624 fcl = wctx[f] | 625 fcl = wctx[f] |
625 fco = mctx[f2] | 626 fco = mctx[f2] |
626 if mctx == actx: # backwards, use working dir parent as ancestor | 627 if mctx == actx: # backwards, use working dir parent as ancestor |
627 if fcl.parents(): | 628 if fcl.parents(): |
628 fca = fcl.p1() | 629 fca = fcl.p1() |
629 else: | 630 else: |
630 fca = repo.filectx(f, fileid=nullrev) | 631 fca = repo.filectx(f, fileid=nullrev) |
632 elif fa in actx: | |
633 fca = actx[fa] | |
631 else: | 634 else: |
632 fca = fcl.ancestor(fco, actx) | |
633 if not fca: | |
634 fca = repo.filectx(f, fileid=nullrev) | 635 fca = repo.filectx(f, fileid=nullrev) |
635 ms.add(fcl, fco, fca, fd) | 636 ms.add(fcl, fco, fca, fd) |
636 if f != fd and move: | 637 if f != fd and move: |
637 moves.append(f) | 638 moves.append(f) |
638 | 639 |
680 | 681 |
681 for i, a in enumerate(actions): | 682 for i, a in enumerate(actions): |
682 f, m, args, msg = a | 683 f, m, args, msg = a |
683 progress(_updating, z + i + 1, item=f, total=numupdates, unit=_files) | 684 progress(_updating, z + i + 1, item=f, total=numupdates, unit=_files) |
684 if m == "m": # merge | 685 if m == "m": # merge |
685 f2, fd, move = args | 686 f2, fa, fd, move = args |
686 if fd == '.hgsubstate': # subrepo states need updating | 687 if fd == '.hgsubstate': # subrepo states need updating |
687 subrepo.submerge(repo, wctx, mctx, wctx.ancestor(mctx), | 688 subrepo.submerge(repo, wctx, mctx, wctx.ancestor(mctx), |
688 overwrite) | 689 overwrite) |
689 continue | 690 continue |
690 audit(fd) | 691 audit(fd) |
790 if branchmerge: | 791 if branchmerge: |
791 repo.dirstate.otherparent(f) | 792 repo.dirstate.otherparent(f) |
792 else: | 793 else: |
793 repo.dirstate.normal(f) | 794 repo.dirstate.normal(f) |
794 elif m == "m": # merge | 795 elif m == "m": # merge |
795 f2, fd, move = args | 796 f2, fa, fd, move = args |
796 if branchmerge: | 797 if branchmerge: |
797 # We've done a branch merge, mark this file as merged | 798 # We've done a branch merge, mark this file as merged |
798 # so that we properly record the merger later | 799 # so that we properly record the merger later |
799 repo.dirstate.merge(fd) | 800 repo.dirstate.merge(fd) |
800 if f != f2: # copy/rename | 801 if f != f2: # copy/rename |