630 actions.sort(key=actionkey) |
630 actions.sort(key=actionkey) |
631 |
631 |
632 # prescan for merges |
632 # prescan for merges |
633 for a in actions: |
633 for a in actions: |
634 f, m, args, msg = a |
634 f, m, args, msg = a |
635 repo.ui.debug(" %s: %s -> %s\n" % (f, msg, m)) |
|
636 if m == "m": # merge |
635 if m == "m": # merge |
637 f1, f2, fa, move, anc = args |
636 f1, f2, fa, move, anc = args |
638 if f == '.hgsubstate': # merged internally |
637 if f == '.hgsubstate': # merged internally |
639 continue |
638 continue |
640 repo.ui.debug(" preserving %s for resolve of %s\n" % (f1, f)) |
639 repo.ui.debug(" preserving %s for resolve of %s\n" % (f1, f)) |
641 fcl = wctx[f1] |
640 fcl = wctx[f1] |
642 fco = mctx[f2] |
641 fco = mctx[f2] |
643 actx = repo[anc] |
642 actx = repo[anc] |
644 if fa in actx: |
643 if fa in actx: |
645 fca = actx[fa] |
644 fca = actx[fa] |
665 workeractions = [a for a in actions if a[1] in 'gr'] |
664 workeractions = [a for a in actions if a[1] in 'gr'] |
666 updateactions = [a for a in workeractions if a[1] == 'g'] |
665 updateactions = [a for a in workeractions if a[1] == 'g'] |
667 updated = len(updateactions) |
666 updated = len(updateactions) |
668 removeactions = [a for a in workeractions if a[1] == 'r'] |
667 removeactions = [a for a in workeractions if a[1] == 'r'] |
669 removed = len(removeactions) |
668 removed = len(removeactions) |
670 actions = [a for a in actions if a[1] not in 'grk'] |
669 actions = [a for a in actions if a[1] not in 'gr'] |
671 |
670 |
672 hgsub = [a[1] for a in workeractions if a[0] == '.hgsubstate'] |
671 hgsub = [a[1] for a in workeractions if a[0] == '.hgsubstate'] |
673 if hgsub and hgsub[0] == 'r': |
672 if hgsub and hgsub[0] == 'r': |
674 subrepo.submerge(repo, wctx, mctx, wctx, overwrite) |
673 subrepo.submerge(repo, wctx, mctx, wctx, overwrite) |
675 |
674 |
689 progress(_updating, z, item=item, total=numupdates, unit=_files) |
688 progress(_updating, z, item=item, total=numupdates, unit=_files) |
690 |
689 |
691 if hgsub and hgsub[0] == 'g': |
690 if hgsub and hgsub[0] == 'g': |
692 subrepo.submerge(repo, wctx, mctx, wctx, overwrite) |
691 subrepo.submerge(repo, wctx, mctx, wctx, overwrite) |
693 |
692 |
694 for i, a in enumerate(actions): |
693 for f, m, args, msg in actions: |
695 f, m, args, msg = a |
694 |
696 progress(_updating, z + i + 1, item=f, total=numupdates, unit=_files) |
695 # forget (manifest only, just log it) (must come first) |
697 if m == "m": # merge |
696 if m == "f": |
|
697 repo.ui.debug(" %s: %s -> f\n" % (f, msg)) |
|
698 z += 1 |
|
699 progress(_updating, z, item=f, total=numupdates, unit=_files) |
|
700 |
|
701 # re-add (manifest only, just log it) |
|
702 elif m == "a": |
|
703 repo.ui.debug(" %s: %s -> a\n" % (f, msg)) |
|
704 z += 1 |
|
705 progress(_updating, z, item=f, total=numupdates, unit=_files) |
|
706 |
|
707 # keep (noop, just log it) |
|
708 elif m == "k": |
|
709 repo.ui.debug(" %s: %s -> k\n" % (f, msg)) |
|
710 # no progress |
|
711 |
|
712 # merge |
|
713 elif m == "m": |
|
714 repo.ui.debug(" %s: %s -> m\n" % (f, msg)) |
|
715 z += 1 |
|
716 progress(_updating, z, item=f, total=numupdates, unit=_files) |
698 f1, f2, fa, move, anc = args |
717 f1, f2, fa, move, anc = args |
699 if f == '.hgsubstate': # subrepo states need updating |
718 if f == '.hgsubstate': # subrepo states need updating |
700 subrepo.submerge(repo, wctx, mctx, wctx.ancestor(mctx), |
719 subrepo.submerge(repo, wctx, mctx, wctx.ancestor(mctx), |
701 overwrite) |
720 overwrite) |
702 continue |
721 continue |
707 else: |
726 else: |
708 if r is None: |
727 if r is None: |
709 updated += 1 |
728 updated += 1 |
710 else: |
729 else: |
711 merged += 1 |
730 merged += 1 |
712 elif m == "dm": # directory rename, move local |
731 |
|
732 # directory rename, move local |
|
733 elif m == "dm": |
|
734 repo.ui.debug(" %s: %s -> dm\n" % (f, msg)) |
|
735 z += 1 |
|
736 progress(_updating, z, item=f, total=numupdates, unit=_files) |
713 f0, flags = args |
737 f0, flags = args |
714 repo.ui.note(_("moving %s to %s\n") % (f0, f)) |
738 repo.ui.note(_("moving %s to %s\n") % (f0, f)) |
715 audit(f) |
739 audit(f) |
716 repo.wwrite(f, wctx.filectx(f0).data(), flags) |
740 repo.wwrite(f, wctx.filectx(f0).data(), flags) |
717 util.unlinkpath(repo.wjoin(f0)) |
741 util.unlinkpath(repo.wjoin(f0)) |
718 updated += 1 |
742 updated += 1 |
719 elif m == "dg": # local directory rename, get |
743 |
|
744 # local directory rename, get |
|
745 elif m == "dg": |
|
746 repo.ui.debug(" %s: %s -> dg\n" % (f, msg)) |
|
747 z += 1 |
|
748 progress(_updating, z, item=f, total=numupdates, unit=_files) |
720 f0, flags = args |
749 f0, flags = args |
721 repo.ui.note(_("getting %s to %s\n") % (f0, f)) |
750 repo.ui.note(_("getting %s to %s\n") % (f0, f)) |
722 repo.wwrite(f, mctx.filectx(f0).data(), flags) |
751 repo.wwrite(f, mctx.filectx(f0).data(), flags) |
723 updated += 1 |
752 updated += 1 |
724 elif m == "dr": # divergent renames |
753 |
|
754 # divergent renames |
|
755 elif m == "dr": |
|
756 repo.ui.debug(" %s: %s -> dr\n" % (f, msg)) |
|
757 z += 1 |
|
758 progress(_updating, z, item=f, total=numupdates, unit=_files) |
725 fl, = args |
759 fl, = args |
726 repo.ui.warn(_("note: possible conflict - %s was renamed " |
760 repo.ui.warn(_("note: possible conflict - %s was renamed " |
727 "multiple times to:\n") % f) |
761 "multiple times to:\n") % f) |
728 for nf in fl: |
762 for nf in fl: |
729 repo.ui.warn(" %s\n" % nf) |
763 repo.ui.warn(" %s\n" % nf) |
730 elif m == "rd": # rename and delete |
764 |
|
765 # rename and delete |
|
766 elif m == "rd": |
|
767 repo.ui.debug(" %s: %s -> rd\n" % (f, msg)) |
|
768 z += 1 |
|
769 progress(_updating, z, item=f, total=numupdates, unit=_files) |
731 fl, = args |
770 fl, = args |
732 repo.ui.warn(_("note: possible conflict - %s was deleted " |
771 repo.ui.warn(_("note: possible conflict - %s was deleted " |
733 "and renamed to:\n") % f) |
772 "and renamed to:\n") % f) |
734 for nf in fl: |
773 for nf in fl: |
735 repo.ui.warn(" %s\n" % nf) |
774 repo.ui.warn(" %s\n" % nf) |
736 elif m == "e": # exec |
775 |
|
776 # exec |
|
777 elif m == "e": |
|
778 repo.ui.debug(" %s: %s -> e\n" % (f, msg)) |
|
779 z += 1 |
|
780 progress(_updating, z, item=f, total=numupdates, unit=_files) |
737 flags, = args |
781 flags, = args |
738 audit(f) |
782 audit(f) |
739 util.setflags(repo.wjoin(f), 'l' in flags, 'x' in flags) |
783 util.setflags(repo.wjoin(f), 'l' in flags, 'x' in flags) |
740 updated += 1 |
784 updated += 1 |
|
785 |
741 ms.commit() |
786 ms.commit() |
742 progress(_updating, None, total=numupdates, unit=_files) |
787 progress(_updating, None, total=numupdates, unit=_files) |
743 |
788 |
744 return updated, merged, removed, unresolved |
789 return updated, merged, removed, unresolved |
745 |
790 |
762 for ancestor in ancestors: |
807 for ancestor in ancestors: |
763 repo.ui.note(_('\ncalculating bids for ancestor %s\n') % ancestor) |
808 repo.ui.note(_('\ncalculating bids for ancestor %s\n') % ancestor) |
764 actions = manifestmerge(repo, wctx, mctx, ancestor, |
809 actions = manifestmerge(repo, wctx, mctx, ancestor, |
765 branchmerge, force, |
810 branchmerge, force, |
766 partial, acceptremote, followcopies) |
811 partial, acceptremote, followcopies) |
767 for a in sorted(actions): |
812 for a in sorted(actions, key=lambda a: (a[1], a)): |
768 f, m, args, msg = a |
813 f, m, args, msg = a |
769 repo.ui.debug(' %s: %s -> %s\n' % (f, msg, m)) |
814 repo.ui.debug(' %s: %s -> %s\n' % (f, msg, m)) |
770 if f in fbids: |
815 if f in fbids: |
771 fbids[f].append(a) |
816 fbids[f].append(a) |
772 else: |
817 else: |
847 return newactions |
892 return newactions |
848 |
893 |
849 def recordupdates(repo, actions, branchmerge): |
894 def recordupdates(repo, actions, branchmerge): |
850 "record merge actions to the dirstate" |
895 "record merge actions to the dirstate" |
851 |
896 |
852 for a in actions: |
897 for f, m, args, msg in actions: |
853 f, m, args, msg = a |
898 |
854 if m == "r": # remove (must come first) |
899 # remove (must come first) |
|
900 if m == "r": # remove |
855 if branchmerge: |
901 if branchmerge: |
856 repo.dirstate.remove(f) |
902 repo.dirstate.remove(f) |
857 else: |
903 else: |
858 repo.dirstate.drop(f) |
904 repo.dirstate.drop(f) |
859 elif m == "f": # forget (must come first) |
905 |
|
906 # forget (must come first) |
|
907 elif m == "f": |
860 repo.dirstate.drop(f) |
908 repo.dirstate.drop(f) |
861 elif m == "a": # re-add |
909 |
|
910 # re-add |
|
911 elif m == "a": |
862 if not branchmerge: |
912 if not branchmerge: |
863 repo.dirstate.add(f) |
913 repo.dirstate.add(f) |
864 elif m == "e": # exec change |
914 |
|
915 # exec change |
|
916 elif m == "e": |
865 repo.dirstate.normallookup(f) |
917 repo.dirstate.normallookup(f) |
866 elif m == "k": # keep |
918 |
|
919 # keep |
|
920 elif m == "k": |
867 pass |
921 pass |
868 elif m == "g": # get |
922 |
|
923 # get |
|
924 elif m == "g": |
869 if branchmerge: |
925 if branchmerge: |
870 repo.dirstate.otherparent(f) |
926 repo.dirstate.otherparent(f) |
871 else: |
927 else: |
872 repo.dirstate.normal(f) |
928 repo.dirstate.normal(f) |
873 elif m == "m": # merge |
929 |
|
930 # merge |
|
931 elif m == "m": |
874 f1, f2, fa, move, anc = args |
932 f1, f2, fa, move, anc = args |
875 if branchmerge: |
933 if branchmerge: |
876 # We've done a branch merge, mark this file as merged |
934 # We've done a branch merge, mark this file as merged |
877 # so that we properly record the merger later |
935 # so that we properly record the merger later |
878 repo.dirstate.merge(f) |
936 repo.dirstate.merge(f) |