[PATCH] obsolete: consider successors along with descendants when updating
Levi Bard
taktaktaktaktaktaktaktaktaktak at gmail.com
Sun Feb 10 15:47:34 CST 2013
# HG changeset patch
# User Levi Bard <levi at unity3d.com>
# Date 1360532614 -3600
# Node ID 8d89080a98d69606ac264282e2ba3e33b056bcac
# Parent 013fcd112f13f31a35ea6a40d8cd1c6923cdaf20
obsolete: consider successors along with descendants when updating
Currently, if you pull --update a group of changesets that obsoletes
the current changeset, mercurial refuses to update because the pulled tip
is not a descendant. This change causes mercurial to consider successors
as well as descendants when determining whether to update.
diff -r 013fcd112f13 -r 8d89080a98d6 mercurial/merge.py
--- a/mercurial/merge.py Sat Feb 09 11:00:42 2013 +0100
+++ b/mercurial/merge.py Sun Feb 10 22:43:34 2013 +0100
@@ -7,6 +7,7 @@
from node import nullid, nullrev, hex, bin
from i18n import _
+from mercurial import obsolete
import error, util, filemerge, copies, subrepo
import errno, os, shutil
@@ -632,6 +633,9 @@
elif not overwrite:
if pa == p1 or pa == p2: # linear
pass # all good
+ elif repo.obsstore and \
+ node in obsolete.allsuccessors(repo.obsstore, [p1.node()]):
+ pa = p1 # allow updating to successors of obsolete nodes
elif wc.dirty(missing=True):
raise util.Abort(_("crosses branches (merge branches or use"
" --clean to discard changes)"))
diff -r 013fcd112f13 -r 8d89080a98d6 tests/test-pull-update.t
--- a/tests/test-pull-update.t Sat Feb 09 11:00:42 2013 +0100
+++ b/tests/test-pull-update.t Sun Feb 10 22:43:34 2013 +0100
@@ -1,3 +1,12 @@
+ $ cat << EOF >> $HGRCPATH
+ > [extensions]
+ > obs=$TESTTMP/obs.py
+ > EOF
+ $ cat > obs.py << EOF
+ > import mercurial.obsolete
+ > mercurial.obsolete._enabled = True
+ > EOF
+
$ hg init t
$ cd t
$ echo 1 > foo
@@ -60,3 +69,64 @@
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd ..
+
+Test no-argument update to a successor of an obsoleted changeset
+
+ $ hg init blah
+ $ cd blah
+ $ echo 1 > a
+ $ hg add a
+ $ hg commit -m0
+ $ echo 2 > a
+ $ hg commit -m1
+ $ cd ..
+ $ hg clone blah meh
+ updating to branch default
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ $ cd blah
+ $ echo 3 > a
+ $ hg commit --amend -m3
+ $ cd ../meh
+ $ hg pull --update ../blah
+ pulling from ../blah
+ searching for changes
+ adding changesets
+ adding manifests
+ adding file changes
+ added 1 changesets with 1 changes to 1 files (+1 heads)
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ $ cd ..
+
+Test refusal to update to a non-successor of an obsoleted changeset
+
+ $ rm -rf blah meh
+ $ hg init blah
+ $ cd blah
+ $ echo 1 > a
+ $ hg add a
+ $ hg commit -m0
+ $ echo 2 > a
+ $ hg commit -m1
+ $ cd ..
+ $ hg clone blah meh
+ updating to branch default
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ $ cd blah
+ $ echo 3 > a
+ $ hg commit --amend -m3
+ $ hg update 0
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ $ echo 4 > a
+ $ hg commit -m4
+ created new head
+ $ cd ../meh
+ $ hg pull --update ../blah
+ pulling from ../blah
+ searching for changes
+ adding changesets
+ adding manifests
+ adding file changes
+ added 2 changesets with 2 changes to 1 files (+2 heads)
+ not updating: crosses branches (merge branches or update --check to force update)
+ $ cd ..
+
More information about the Mercurial-devel
mailing list