Fix income/pull with bundle and -R (issue 820).
Uses ui.setconfig() to tell bundlerepo where the main repo is. This is
needed for when the --repository option is used.
Adds tests to test-bundle and a new test script
test-mq-pull-from-bundle, which plays out the situation that initially
made me detect this bug
(hg -R .hg/patches pull ../bundle.hg).
--- a/mercurial/bundlerepo.py Sat Nov 03 11:11:13 2007 +0100
+++ b/mercurial/bundlerepo.py Tue Dec 18 14:11:13 2007 -0600
@@ -256,14 +256,25 @@
def instance(ui, path, create):
if create:
raise util.Abort(_('cannot create new bundle repository'))
+ parentpath = ui.config("bundle", "mainreporoot", "")
+ if parentpath:
+ # Try to make the full path relative so we get a nice, short URL.
+ # In particular, we don't want temp dir names in test outputs.
+ cwd = os.getcwd()
+ if parentpath == cwd:
+ parentpath = ''
+ else:
+ cwd = os.path.join(cwd,'')
+ if parentpath.startswith(cwd):
+ parentpath = parentpath[len(cwd):]
path = util.drop_scheme('file', path)
if path.startswith('bundle:'):
path = util.drop_scheme('bundle', path)
s = path.split("+", 1)
if len(s) == 1:
- repopath, bundlename = "", s[0]
+ repopath, bundlename = parentpath, s[0]
else:
repopath, bundlename = s
else:
- repopath, bundlename = '', path
+ repopath, bundlename = parentpath, path
return bundlerepository(ui, repopath, bundlename)
--- a/mercurial/dispatch.py Sat Nov 03 11:11:13 2007 +0100
+++ b/mercurial/dispatch.py Tue Dec 18 14:11:13 2007 -0600
@@ -331,6 +331,7 @@
try:
repo = hg.repository(ui, path=path)
ui = repo.ui
+ ui.setconfig("bundle", "mainreporoot", repo.root)
if not repo.local():
raise util.Abort(_("repository '%s' is not local") % path)
except hg.RepoError:
--- a/tests/test-bundle Sat Nov 03 11:11:13 2007 +0100
+++ b/tests/test-bundle Tue Dec 18 14:11:13 2007 -0600
@@ -49,6 +49,15 @@
echo "====== Pull full.hg into empty again (using --cwd)"
hg --cwd empty pull ../full.hg
+echo "====== Pull full.hg into test (using -R)"
+hg -R test pull full.hg
+echo "====== Pull full.hg into empty (using -R)"
+hg -R empty pull full.hg
+echo "====== Rollback empty"
+hg -R empty rollback
+echo "====== Pull full.hg into empty again (using -R)"
+hg -R empty pull full.hg
+
echo "====== Log -R full.hg in fresh empty"
rm -r empty
hg init empty
--- a/tests/test-bundle.out Sat Nov 03 11:11:13 2007 +0100
+++ b/tests/test-bundle.out Tue Dec 18 14:11:13 2007 -0600
@@ -47,6 +47,24 @@
adding file changes
added 9 changesets with 7 changes to 4 files (+1 heads)
(run 'hg heads' to see heads, 'hg merge' to merge)
+====== Pull full.hg into test (using -R)
+pulling from full.hg
+searching for changes
+no changes found
+====== Pull full.hg into empty (using -R)
+pulling from full.hg
+searching for changes
+no changes found
+====== Rollback empty
+rolling back last transaction
+====== Pull full.hg into empty again (using -R)
+pulling from full.hg
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 9 changesets with 7 changes to 4 files (+1 heads)
+(run 'hg heads' to see heads, 'hg merge' to merge)
====== Log -R full.hg in fresh empty
changeset: 8:836ac62537ab
tag: tip
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-mq-pull-from-bundle Tue Dec 18 14:11:13 2007 -0600
@@ -0,0 +1,84 @@
+#!/bin/sh
+
+echo "[extensions]" >> $HGRCPATH
+echo "mq=" >> $HGRCPATH
+echo "[defaults]" >> $HGRCPATH
+echo "log = --template \"{rev}: {desc}\\n\"" >> $HGRCPATH
+echo "heads = --template \"{rev}: {desc}\\n\"" >> $HGRCPATH
+echo "incoming = --template \"{rev}: {desc}\\n\"" >> $HGRCPATH
+
+echo "====== .hgrc"
+cat $HGRCPATH
+
+echo "====== Setup main"
+hg init base
+cd base
+echo "One" > one
+hg add
+hg ci -m "main: one added."
+echo "++" >> one
+hg ci -m "main: one updated."
+
+echo "====== Bundle main"
+hg bundle --base=null ../main.hg
+cd ..
+
+echo "====== Incoming to fresh repo"
+hg init fresh
+echo ">> hg -R fresh incoming main.hg"
+hg -R fresh incoming main.hg
+echo ">> hg -R fresh incoming bundle:fresh+main.hg"
+hg -R fresh incoming bundle:fresh+main.hg
+
+
+echo "====== Setup queue"
+cd base
+hg qinit -c
+hg qnew -m "patch: two added." two.patch
+echo two > two
+hg add
+hg qrefresh
+hg qcommit -m "queue: two.patch added."
+hg qpop -a
+
+echo "====== Bundle queue"
+hg -R .hg/patches bundle --base=null ../queue.hgq
+cd ..
+
+
+echo "====== Clone base"
+hg clone base copy
+cd copy
+hg qinit -c
+
+echo "====== Incoming queue bundle"
+echo ">> hg -R .hg/patches incoming ../queue.hgq"
+hg -R .hg/patches incoming ../queue.hgq
+
+echo "====== Pull queue bundle"
+echo ">> hg -R .hg/patches pull --update ../queue.hgq"
+hg -R .hg/patches pull --update ../queue.hgq
+echo ">> hg -R .hg/patches heads"
+hg -R .hg/patches heads
+echo ">> hg -R .hg/patches log"
+hg -R .hg/patches log
+echo ">> hg qseries"
+hg qseries
+cd ..
+
+
+echo "====== Clone base again"
+hg clone base copy2
+cd copy2
+hg qinit -c
+
+echo "====== Unbundle queue bundle"
+echo ">> hg -R .hg/patches unbundle --update ../queue.hgq"
+hg -R .hg/patches unbundle --update ../queue.hgq
+echo ">> hg -R .hg/patches heads"
+hg -R .hg/patches heads
+echo ">> hg -R .hg/patches log"
+hg -R .hg/patches log
+echo ">> hg qseries"
+hg qseries
+cd ..
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-mq-pull-from-bundle.out Tue Dec 18 14:11:13 2007 -0600
@@ -0,0 +1,68 @@
+====== .hgrc
+[ui]
+slash = True
+[defaults]
+backout = -d "0 0"
+commit = -d "0 0"
+debugrawcommit = -d "0 0"
+tag = -d "0 0"
+[extensions]
+mq=
+[defaults]
+log = --template "{rev}: {desc}\n"
+heads = --template "{rev}: {desc}\n"
+incoming = --template "{rev}: {desc}\n"
+====== Setup main
+adding one
+====== Bundle main
+====== Incoming to fresh repo
+>> hg -R fresh incoming main.hg
+comparing with main.hg
+0: main: one added.
+1: main: one updated.
+>> hg -R fresh incoming bundle:fresh+main.hg
+comparing with bundle:fresh+main.hg
+0: main: one added.
+1: main: one updated.
+====== Setup queue
+adding two
+Patch queue now empty
+====== Bundle queue
+====== Clone base
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+====== Incoming queue bundle
+>> hg -R .hg/patches incoming ../queue.hgq
+comparing with ../queue.hgq
+0: queue: two.patch added.
+====== Pull queue bundle
+>> hg -R .hg/patches pull --update ../queue.hgq
+pulling from ../queue.hgq
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 3 changes to 3 files
+merging series
+2 files updated, 1 files merged, 0 files removed, 0 files unresolved
+>> hg -R .hg/patches heads
+0: queue: two.patch added.
+>> hg -R .hg/patches log
+0: queue: two.patch added.
+>> hg qseries
+two.patch
+====== Clone base again
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+====== Unbundle queue bundle
+>> hg -R .hg/patches unbundle --update ../queue.hgq
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 3 changes to 3 files
+merging series
+2 files updated, 1 files merged, 0 files removed, 0 files unresolved
+>> hg -R .hg/patches heads
+0: queue: two.patch added.
+>> hg -R .hg/patches log
+0: queue: two.patch added.
+>> hg qseries
+two.patch