# HG changeset patch # User Mads Kiilerich # Date 2010-10-26 22:28:40 # Node ID 5dbff89cf1070a578c53f347d734a57962608713 # Parent 765c98f068d3ce41b7c0df161d5e39b9c362926e subrepo: propagate non-default pull/push path to relative subrepos (issue1852) diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2784,7 +2784,11 @@ def pull(ui, repo, source="default", **o modheads = repo.pull(other, heads=revs, force=opts.get('force')) if checkout: checkout = str(repo.changelog.rev(other.lookup(checkout))) - return postincoming(ui, repo, modheads, opts.get('update'), checkout) + repo._subtoppath = source + try: + return postincoming(ui, repo, modheads, opts.get('update'), checkout) + finally: + del repo._subtoppath def push(ui, repo, dest=None, **opts): """push changes to the specified destination @@ -2823,13 +2827,16 @@ def push(ui, repo, dest=None, **opts): if revs: revs = [repo.lookup(rev) for rev in revs] - # push subrepos depth-first for coherent ordering - c = repo[''] - subs = c.substate # only repos that are committed - for s in sorted(subs): - if not c.sub(s).push(opts.get('force')): - return False - + repo._subtoppath = dest + try: + # push subrepos depth-first for coherent ordering + c = repo[''] + subs = c.substate # only repos that are committed + for s in sorted(subs): + if not c.sub(s).push(opts.get('force')): + return False + finally: + del repo._subtoppath r = repo.push(other, opts.get('force'), revs=revs, newbranch=opts.get('new_branch')) return r == 0 diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -187,6 +187,8 @@ def _abssource(repo, push=False, abort=T else: # plain file system path return posixpath.normpath(os.path.join(parent, repo._subsource)) else: # recursion reached top repo + if hasattr(repo, '_subtoppath'): + return repo._subtoppath if push and repo.ui.config('paths', 'default-push'): return repo.ui.config('paths', 'default-push') if repo.ui.config('paths', 'default'): diff --git a/tests/test-subrepo.t b/tests/test-subrepo.t --- a/tests/test-subrepo.t +++ b/tests/test-subrepo.t @@ -636,12 +636,23 @@ Try the same, but with pull -u adding manifests adding file changes added 1 changesets with 2 changes to 2 files - abort: default path for subrepository sub/repo not found - [255] + pulling subrepo sub/repo from issue1852a/sub/repo + requesting all changes + adding changesets + adding manifests + adding file changes + added 2 changesets with 2 changes to 1 files + 2 files updated, 0 files merged, 0 files removed, 0 files unresolved Try to push from the other side - $ hg -R issue1852a push issue1852c - pushing to issue1852c - abort: default path for subrepository sub/repo not found - [255] + $ hg -R issue1852a push `pwd`/issue1852c + pushing to $TESTTMP/sub/issue1852c + pushing subrepo sub/repo to $TESTTMP/sub/issue1852c/sub/repo + searching for changes + no changes found + searching for changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 1 changes to 1 files