comparison mercurial/merge.py @ 21081:ffd7b6ce46ff

merge: pass merge ancestor to calculateupdates as a list The list will so far always have one element.
author Mads Kiilerich <madski@unity3d.com>
date Sun, 06 Apr 2014 13:39:51 +0200
parents 04540a8499a3
children 0d67fccc0d43
comparison
equal deleted inserted replaced
21080:04540a8499a3 21081:ffd7b6ce46ff
717 ms.commit() 717 ms.commit()
718 progress(_updating, None, total=numupdates, unit=_files) 718 progress(_updating, None, total=numupdates, unit=_files)
719 719
720 return updated, merged, removed, unresolved 720 return updated, merged, removed, unresolved
721 721
722 def calculateupdates(repo, wctx, mctx, ancestor, branchmerge, force, partial, 722 def calculateupdates(repo, wctx, mctx, ancestors, branchmerge, force, partial,
723 acceptremote, followcopies): 723 acceptremote, followcopies):
724 "Calculate the actions needed to merge mctx into wctx using ancestor" 724 "Calculate the actions needed to merge mctx into wctx using ancestors"
725
726 ancestor = ancestors[0]
725 727
726 actions = manifestmerge(repo, wctx, mctx, 728 actions = manifestmerge(repo, wctx, mctx,
727 ancestor, 729 ancestor,
728 branchmerge, force, 730 branchmerge, force,
729 partial, acceptremote, followcopies) 731 partial, acceptremote, followcopies)
873 wlock = repo.wlock() 875 wlock = repo.wlock()
874 try: 876 try:
875 wc = repo[None] 877 wc = repo[None]
876 pl = wc.parents() 878 pl = wc.parents()
877 p1 = pl[0] 879 p1 = pl[0]
878 pa = None 880 pas = [None]
879 if ancestor: 881 if ancestor:
880 pa = repo[ancestor] 882 pas = [repo[ancestor]]
881 883
882 if node is None: 884 if node is None:
883 # Here is where we should consider bookmarks, divergent bookmarks, 885 # Here is where we should consider bookmarks, divergent bookmarks,
884 # foreground changesets (successors), and tip of current branch; 886 # foreground changesets (successors), and tip of current branch;
885 # but currently we are only checking the branch tips. 887 # but currently we are only checking the branch tips.
914 successors = [n for sub in successors for n in sub] 916 successors = [n for sub in successors for n in sub]
915 917
916 # get the max revision for the given successors set, 918 # get the max revision for the given successors set,
917 # i.e. the 'tip' of a set 919 # i.e. the 'tip' of a set
918 node = repo.revs("max(%ln)", successors)[0] 920 node = repo.revs("max(%ln)", successors)[0]
919 pa = p1 921 pas = [p1]
920 922
921 overwrite = force and not branchmerge 923 overwrite = force and not branchmerge
922 924
923 p2 = repo[node] 925 p2 = repo[node]
924 if pa is None: 926 if pas[0] is None:
925 pa = p1.ancestor(p2) 927 pas = [p1.ancestor(p2)]
926 928
927 fp1, fp2, xp1, xp2 = p1.node(), p2.node(), str(p1), str(p2) 929 fp1, fp2, xp1, xp2 = p1.node(), p2.node(), str(p1), str(p2)
928 930
929 ### check phase 931 ### check phase
930 if not overwrite and len(pl) > 1: 932 if not overwrite and len(pl) > 1:
931 raise util.Abort(_("outstanding uncommitted merges")) 933 raise util.Abort(_("outstanding uncommitted merges"))
932 if branchmerge: 934 if branchmerge:
933 if pa == p2: 935 if pas == [p2]:
934 raise util.Abort(_("merging with a working directory ancestor" 936 raise util.Abort(_("merging with a working directory ancestor"
935 " has no effect")) 937 " has no effect"))
936 elif pa == p1: 938 elif pas == [p1]:
937 if not mergeancestor and p1.branch() == p2.branch(): 939 if not mergeancestor and p1.branch() == p2.branch():
938 raise util.Abort(_("nothing to merge"), 940 raise util.Abort(_("nothing to merge"),
939 hint=_("use 'hg update' " 941 hint=_("use 'hg update' "
940 "or check 'hg heads'")) 942 "or check 'hg heads'"))
941 if not force and (wc.files() or wc.deleted()): 943 if not force and (wc.files() or wc.deleted()):
951 # call the hooks and exit early 953 # call the hooks and exit early
952 repo.hook('preupdate', throw=True, parent1=xp2, parent2='') 954 repo.hook('preupdate', throw=True, parent1=xp2, parent2='')
953 repo.hook('update', parent1=xp2, parent2='', error=0) 955 repo.hook('update', parent1=xp2, parent2='', error=0)
954 return 0, 0, 0, 0 956 return 0, 0, 0, 0
955 957
956 if pa not in (p1, p2): # nonlinear 958 if pas not in ([p1], [p2]): # nonlinear
957 dirty = wc.dirty(missing=True) 959 dirty = wc.dirty(missing=True)
958 if dirty or onode is None: 960 if dirty or onode is None:
959 # Branching is a bit strange to ensure we do the minimal 961 # Branching is a bit strange to ensure we do the minimal
960 # amount of call to obsolete.background. 962 # amount of call to obsolete.background.
961 foreground = obsolete.foreground(repo, [p1.node()]) 963 foreground = obsolete.foreground(repo, [p1.node()])
962 # note: the <node> variable contains a random identifier 964 # note: the <node> variable contains a random identifier
963 if repo[node].node() in foreground: 965 if repo[node].node() in foreground:
964 pa = p1 # allow updating to successors 966 pas = [p1] # allow updating to successors
965 elif dirty: 967 elif dirty:
966 msg = _("uncommitted changes") 968 msg = _("uncommitted changes")
967 if onode is None: 969 if onode is None:
968 hint = _("commit and merge, or update --clean to" 970 hint = _("commit and merge, or update --clean to"
969 " discard changes") 971 " discard changes")
975 msg = _("not a linear update") 977 msg = _("not a linear update")
976 hint = _("merge or update --check to force update") 978 hint = _("merge or update --check to force update")
977 raise util.Abort(msg, hint=hint) 979 raise util.Abort(msg, hint=hint)
978 else: 980 else:
979 # Allow jumping branches if clean and specific rev given 981 # Allow jumping branches if clean and specific rev given
980 pa = p1 982 pas = [p1]
981 983
982 followcopies = False 984 followcopies = False
983 if overwrite: 985 if overwrite:
984 pa = wc 986 pas = [wc]
985 elif pa == p2: # backwards 987 elif pas == [p2]: # backwards
986 pa = wc.p1() 988 pas = [wc.p1()]
987 elif not branchmerge and not wc.dirty(missing=True): 989 elif not branchmerge and not wc.dirty(missing=True):
988 pass 990 pass
989 elif pa and repo.ui.configbool("merge", "followcopies", True): 991 elif pas[0] and repo.ui.configbool("merge", "followcopies", True):
990 followcopies = True 992 followcopies = True
991 993
992 ### calculate phase 994 ### calculate phase
993 actions = calculateupdates(repo, wc, p2, pa, branchmerge, force, 995 actions = calculateupdates(repo, wc, p2, pas, branchmerge, force,
994 partial, mergeancestor, followcopies) 996 partial, mergeancestor, followcopies)
995 997
996 ### apply phase 998 ### apply phase
997 if not branchmerge: # just jump to the new rev 999 if not branchmerge: # just jump to the new rev
998 fp1, fp2, xp1, xp2 = fp2, nullid, xp2, '' 1000 fp1, fp2, xp1, xp2 = fp2, nullid, xp2, ''