# HG changeset patch # User Peter Arrenbrecht # Date 2007-12-18 20:11:13 # Node ID da72b4d2479770d7682eda3dde8b8ad64fec9b14 # Parent 99fdef2e679331c293b3bd0c36696cfc5db4cc6f 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). diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py --- a/mercurial/bundlerepo.py +++ b/mercurial/bundlerepo.py @@ -256,14 +256,25 @@ class bundlerepository(localrepo.localre 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) diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -331,6 +331,7 @@ def _dispatch(ui, args): 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: diff --git a/tests/test-bundle b/tests/test-bundle --- a/tests/test-bundle +++ b/tests/test-bundle @@ -49,6 +49,15 @@ hg -R empty rollback 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 diff --git a/tests/test-bundle.out b/tests/test-bundle.out --- a/tests/test-bundle.out +++ b/tests/test-bundle.out @@ -47,6 +47,24 @@ 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) +====== 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 diff --git a/tests/test-mq-pull-from-bundle b/tests/test-mq-pull-from-bundle new file mode 100755 --- /dev/null +++ b/tests/test-mq-pull-from-bundle @@ -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 .. diff --git a/tests/test-mq-pull-from-bundle.out b/tests/test-mq-pull-from-bundle.out new file mode 100644 --- /dev/null +++ b/tests/test-mq-pull-from-bundle.out @@ -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