[PATCH 3 of 6 V2] merge: move foreground logic earlier
Sean Farley
sean.michael.farley at gmail.com
Sun Jan 12 16:25:51 CST 2014
# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1389549596 21600
# Sun Jan 12 11:59:56 2014 -0600
# Node ID 460212c85977dbeec5007558fa26293a4a0d11f4
# Parent 1908bcdb50a7b4be9eca3e90274365355783efe7
merge: move foreground logic earlier
This changeset doesn't change any previous logic. It is mainly prepatory work
for the next few changesets which will use this foreground calculation for
guessing which head to update to.
This earlier check for foreground changes is protected by two conditions: it
only happens in a bare update (no node is provided) *and* if the head that was
previously guessed (using branchtip or tip concepts without knowledge of
obsolesence) is currently obsolete.
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -695,10 +695,19 @@ def update(repo, node, branchmerge, forc
except error.RepoLookupError:
if wc.branch() == "default": # no default branch!
node = repo.lookup("tip") # update to tip
else:
raise util.Abort(_("branch %s not found") % wc.branch())
+
+ # We only check for foreground (successor) changesets if the node
+ # found by the above logic is obsolete
+ if repo[node].obsolete():
+ # Branching is a bit strange to ensure we do the minimal
+ # amount of call to obsolete.background.
+ foreground = obsolete.foreground(repo, [p1.node()])
+ # note: the <node> variable contains a random identifier
+
overwrite = force and not branchmerge
p2 = repo[node]
if pa is None:
pa = p1.ancestor(p2)
@@ -733,14 +742,12 @@ def update(repo, node, branchmerge, forc
return 0, 0, 0, 0
if pa not in (p1, p2): # nonlinear
dirty = wc.dirty(missing=True)
if dirty or onode is None:
- # Branching is a bit strange to ensure we do the minimal
- # amount of call to obsolete.background.
- foreground = obsolete.foreground(repo, [p1.node()])
- # note: the <node> variable contains a random identifier
+ if foreground is None:
+ foreground = obsolete.foreground(repo, [p1.node()])
if repo[node].node() in foreground:
pa = p1 # allow updating to successors
elif dirty:
msg = _("uncommitted changes")
if onode is None:
More information about the Mercurial-devel
mailing list