[PATCH 4 of 6 V2] merge: include obsolete calculation for branchtips
Sean Farley
sean.michael.farley at gmail.com
Sun Jan 12 16:25:52 CST 2014
# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1383779296 21600
# Wed Nov 06 17:08:16 2013 -0600
# Node ID b97f7e3553f1694abd360e30c0e4a9eac59f393a
# Parent 460212c85977dbeec5007558fa26293a4a0d11f4
merge: include obsolete calculation for branchtips
Previously, a bare update would ignore any successor changesets thus
potentially leaving you on an obsolete head. This happens commonly when there
is an old bookmark that hasn't been moved forward which is the motivating
reason for this patch series.
Now, we will check for successor changesets if two conditions hold:
1) we are doing a bare update
2) *and* the branchtip returned normally is obsolete
If we are in this situation, then we calculate the branchtip of the successor
set and update to that changeset.
In addition, we also preserves the no-op update clause added by Siddharth
Agarwal in ab2362e1672e by checking that the successor set is not the same as
set(p1).
Tests will be updated in the next patch because it requires a non-obvious fix
to the test case.
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -704,10 +704,17 @@ def update(repo, node, branchmerge, forc
# 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
+ # allow updating to successors
+ if repo[node].node() in foreground:
+ # get the max revision for the given foreground set
+ unfil = [repo.unfiltered()[n].rev() for n in foreground]
+ node = repo[max(unfil)].node()
+ pa = p1
+
overwrite = force and not branchmerge
p2 = repo[node]
if pa is None:
pa = p1.ancestor(p2)
@@ -733,11 +740,13 @@ def update(repo, node, branchmerge, forc
if wc.sub(s).dirty():
raise util.Abort(_("uncommitted changes in "
"subrepository '%s'") % s)
elif not overwrite:
- if p1 == p2: # no-op update
+ # no-op update
+ if (p1 == p2 and
+ not (foreground and foreground != set([p1.node()]))):
# call the hooks and exit early
repo.hook('preupdate', throw=True, parent1=xp2, parent2='')
repo.hook('update', parent1=xp2, parent2='', error=0)
return 0, 0, 0, 0
More information about the Mercurial-devel
mailing list