Show More
@@ -522,6 +522,105 b' def manifestmerge(repo, wctx, p2, pa, br' | |||
|
522 | 522 | |
|
523 | 523 | return actions |
|
524 | 524 | |
|
525 | def calculateupdates(repo, wctx, mctx, ancestors, branchmerge, force, partial, | |
|
526 | acceptremote, followcopies): | |
|
527 | "Calculate the actions needed to merge mctx into wctx using ancestors" | |
|
528 | ||
|
529 | if len(ancestors) == 1: # default | |
|
530 | actions = manifestmerge(repo, wctx, mctx, ancestors[0], | |
|
531 | branchmerge, force, | |
|
532 | partial, acceptremote, followcopies) | |
|
533 | ||
|
534 | else: # only when merge.preferancestor=* - the default | |
|
535 | repo.ui.note( | |
|
536 | _("note: merging %s and %s using bids from ancestors %s\n") % | |
|
537 | (wctx, mctx, _(' and ').join(str(anc) for anc in ancestors))) | |
|
538 | ||
|
539 | # Call for bids | |
|
540 | fbids = {} # mapping filename to bids (action method to list af actions) | |
|
541 | for ancestor in ancestors: | |
|
542 | repo.ui.note(_('\ncalculating bids for ancestor %s\n') % ancestor) | |
|
543 | actions = manifestmerge(repo, wctx, mctx, ancestor, | |
|
544 | branchmerge, force, | |
|
545 | partial, acceptremote, followcopies) | |
|
546 | for m, l in sorted(actions.items()): | |
|
547 | for a in l: | |
|
548 | f, args, msg = a | |
|
549 | repo.ui.debug(' %s: %s -> %s\n' % (f, msg, m)) | |
|
550 | if f in fbids: | |
|
551 | d = fbids[f] | |
|
552 | if m in d: | |
|
553 | d[m].append(a) | |
|
554 | else: | |
|
555 | d[m] = [a] | |
|
556 | else: | |
|
557 | fbids[f] = {m: [a]} | |
|
558 | ||
|
559 | # Pick the best bid for each file | |
|
560 | repo.ui.note(_('\nauction for merging merge bids\n')) | |
|
561 | actions = dict((m, []) for m in actions.keys()) | |
|
562 | for f, bids in sorted(fbids.items()): | |
|
563 | # bids is a mapping from action method to list af actions | |
|
564 | # Consensus? | |
|
565 | if len(bids) == 1: # all bids are the same kind of method | |
|
566 | m, l = bids.items()[0] | |
|
567 | if util.all(a == l[0] for a in l[1:]): # len(bids) is > 1 | |
|
568 | repo.ui.note(" %s: consensus for %s\n" % (f, m)) | |
|
569 | actions[m].append(l[0]) | |
|
570 | continue | |
|
571 | # If keep is an option, just do it. | |
|
572 | if 'k' in bids: | |
|
573 | repo.ui.note(" %s: picking 'keep' action\n" % f) | |
|
574 | actions['k'].append(bids['k'][0]) | |
|
575 | continue | |
|
576 | # If there are gets and they all agree [how could they not?], do it. | |
|
577 | if 'g' in bids: | |
|
578 | ga0 = bids['g'][0] | |
|
579 | if util.all(a == ga0 for a in bids['g'][1:]): | |
|
580 | repo.ui.note(" %s: picking 'get' action\n" % f) | |
|
581 | actions['g'].append(ga0) | |
|
582 | continue | |
|
583 | # TODO: Consider other simple actions such as mode changes | |
|
584 | # Handle inefficient democrazy. | |
|
585 | repo.ui.note(_(' %s: multiple bids for merge action:\n') % f) | |
|
586 | for m, l in sorted(bids.items()): | |
|
587 | for _f, args, msg in l: | |
|
588 | repo.ui.note(' %s -> %s\n' % (msg, m)) | |
|
589 | # Pick random action. TODO: Instead, prompt user when resolving | |
|
590 | m, l = bids.items()[0] | |
|
591 | repo.ui.warn(_(' %s: ambiguous merge - picked %s action\n') % | |
|
592 | (f, m)) | |
|
593 | actions[m].append(l[0]) | |
|
594 | continue | |
|
595 | repo.ui.note(_('end of auction\n\n')) | |
|
596 | ||
|
597 | # Prompt and create actions. TODO: Move this towards resolve phase. | |
|
598 | for f, args, msg in actions['cd']: | |
|
599 | if repo.ui.promptchoice( | |
|
600 | _("local changed %s which remote deleted\n" | |
|
601 | "use (c)hanged version or (d)elete?" | |
|
602 | "$$ &Changed $$ &Delete") % f, 0): | |
|
603 | actions['r'].append((f, None, "prompt delete")) | |
|
604 | else: | |
|
605 | actions['a'].append((f, None, "prompt keep")) | |
|
606 | del actions['cd'][:] | |
|
607 | ||
|
608 | for f, args, msg in actions['dc']: | |
|
609 | flags, = args | |
|
610 | if repo.ui.promptchoice( | |
|
611 | _("remote changed %s which local deleted\n" | |
|
612 | "use (c)hanged version or leave (d)eleted?" | |
|
613 | "$$ &Changed $$ &Deleted") % f, 0) == 0: | |
|
614 | actions['g'].append((f, (flags,), "prompt recreating")) | |
|
615 | del actions['dc'][:] | |
|
616 | ||
|
617 | if wctx.rev() is None: | |
|
618 | ractions, factions = _forgetremoved(wctx, mctx, branchmerge) | |
|
619 | actions['r'].extend(ractions) | |
|
620 | actions['f'].extend(factions) | |
|
621 | ||
|
622 | return actions | |
|
623 | ||
|
525 | 624 | def batchremove(repo, actions): |
|
526 | 625 | """apply removes to the working directory |
|
527 | 626 | |
@@ -737,105 +836,6 b' def applyupdates(repo, actions, wctx, mc' | |||
|
737 | 836 | |
|
738 | 837 | return updated, merged, removed, unresolved |
|
739 | 838 | |
|
740 | def calculateupdates(repo, wctx, mctx, ancestors, branchmerge, force, partial, | |
|
741 | acceptremote, followcopies): | |
|
742 | "Calculate the actions needed to merge mctx into wctx using ancestors" | |
|
743 | ||
|
744 | if len(ancestors) == 1: # default | |
|
745 | actions = manifestmerge(repo, wctx, mctx, ancestors[0], | |
|
746 | branchmerge, force, | |
|
747 | partial, acceptremote, followcopies) | |
|
748 | ||
|
749 | else: # only when merge.preferancestor=* - the default | |
|
750 | repo.ui.note( | |
|
751 | _("note: merging %s and %s using bids from ancestors %s\n") % | |
|
752 | (wctx, mctx, _(' and ').join(str(anc) for anc in ancestors))) | |
|
753 | ||
|
754 | # Call for bids | |
|
755 | fbids = {} # mapping filename to bids (action method to list af actions) | |
|
756 | for ancestor in ancestors: | |
|
757 | repo.ui.note(_('\ncalculating bids for ancestor %s\n') % ancestor) | |
|
758 | actions = manifestmerge(repo, wctx, mctx, ancestor, | |
|
759 | branchmerge, force, | |
|
760 | partial, acceptremote, followcopies) | |
|
761 | for m, l in sorted(actions.items()): | |
|
762 | for a in l: | |
|
763 | f, args, msg = a | |
|
764 | repo.ui.debug(' %s: %s -> %s\n' % (f, msg, m)) | |
|
765 | if f in fbids: | |
|
766 | d = fbids[f] | |
|
767 | if m in d: | |
|
768 | d[m].append(a) | |
|
769 | else: | |
|
770 | d[m] = [a] | |
|
771 | else: | |
|
772 | fbids[f] = {m: [a]} | |
|
773 | ||
|
774 | # Pick the best bid for each file | |
|
775 | repo.ui.note(_('\nauction for merging merge bids\n')) | |
|
776 | actions = dict((m, []) for m in actions.keys()) | |
|
777 | for f, bids in sorted(fbids.items()): | |
|
778 | # bids is a mapping from action method to list af actions | |
|
779 | # Consensus? | |
|
780 | if len(bids) == 1: # all bids are the same kind of method | |
|
781 | m, l = bids.items()[0] | |
|
782 | if util.all(a == l[0] for a in l[1:]): # len(bids) is > 1 | |
|
783 | repo.ui.note(" %s: consensus for %s\n" % (f, m)) | |
|
784 | actions[m].append(l[0]) | |
|
785 | continue | |
|
786 | # If keep is an option, just do it. | |
|
787 | if 'k' in bids: | |
|
788 | repo.ui.note(" %s: picking 'keep' action\n" % f) | |
|
789 | actions['k'].append(bids['k'][0]) | |
|
790 | continue | |
|
791 | # If there are gets and they all agree [how could they not?], do it. | |
|
792 | if 'g' in bids: | |
|
793 | ga0 = bids['g'][0] | |
|
794 | if util.all(a == ga0 for a in bids['g'][1:]): | |
|
795 | repo.ui.note(" %s: picking 'get' action\n" % f) | |
|
796 | actions['g'].append(ga0) | |
|
797 | continue | |
|
798 | # TODO: Consider other simple actions such as mode changes | |
|
799 | # Handle inefficient democrazy. | |
|
800 | repo.ui.note(_(' %s: multiple bids for merge action:\n') % f) | |
|
801 | for m, l in sorted(bids.items()): | |
|
802 | for _f, args, msg in l: | |
|
803 | repo.ui.note(' %s -> %s\n' % (msg, m)) | |
|
804 | # Pick random action. TODO: Instead, prompt user when resolving | |
|
805 | m, l = bids.items()[0] | |
|
806 | repo.ui.warn(_(' %s: ambiguous merge - picked %s action\n') % | |
|
807 | (f, m)) | |
|
808 | actions[m].append(l[0]) | |
|
809 | continue | |
|
810 | repo.ui.note(_('end of auction\n\n')) | |
|
811 | ||
|
812 | # Prompt and create actions. TODO: Move this towards resolve phase. | |
|
813 | for f, args, msg in actions['cd']: | |
|
814 | if repo.ui.promptchoice( | |
|
815 | _("local changed %s which remote deleted\n" | |
|
816 | "use (c)hanged version or (d)elete?" | |
|
817 | "$$ &Changed $$ &Delete") % f, 0): | |
|
818 | actions['r'].append((f, None, "prompt delete")) | |
|
819 | else: | |
|
820 | actions['a'].append((f, None, "prompt keep")) | |
|
821 | del actions['cd'][:] | |
|
822 | ||
|
823 | for f, args, msg in actions['dc']: | |
|
824 | flags, = args | |
|
825 | if repo.ui.promptchoice( | |
|
826 | _("remote changed %s which local deleted\n" | |
|
827 | "use (c)hanged version or leave (d)eleted?" | |
|
828 | "$$ &Changed $$ &Deleted") % f, 0) == 0: | |
|
829 | actions['g'].append((f, (flags,), "prompt recreating")) | |
|
830 | del actions['dc'][:] | |
|
831 | ||
|
832 | if wctx.rev() is None: | |
|
833 | ractions, factions = _forgetremoved(wctx, mctx, branchmerge) | |
|
834 | actions['r'].extend(ractions) | |
|
835 | actions['f'].extend(factions) | |
|
836 | ||
|
837 | return actions | |
|
838 | ||
|
839 | 839 | def recordupdates(repo, actions, branchmerge): |
|
840 | 840 | "record merge actions to the dirstate" |
|
841 | 841 | # remove (must come first) |
General Comments 0
You need to be logged in to leave comments.
Login now