subrepo: propagate non-default pull/push path to relative subrepos (issue1852) stable
authorMads Kiilerich <mads@kiilerich.com>
Wed, 27 Oct 2010 00:28:40 +0200
branchstable
changeset 12852 5dbff89cf107
parent 12851 765c98f068d3
child 12853 13984e96cb09
subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
mercurial/commands.py
mercurial/subrepo.py
tests/test-subrepo.t
--- a/mercurial/commands.py	Tue Oct 26 14:41:58 2010 +0300
+++ b/mercurial/commands.py	Wed Oct 27 00:28:40 2010 +0200
@@ -2784,7 +2784,11 @@
     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 @@
     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
--- a/mercurial/subrepo.py	Tue Oct 26 14:41:58 2010 +0300
+++ b/mercurial/subrepo.py	Wed Oct 27 00:28:40 2010 +0200
@@ -187,6 +187,8 @@
             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'):
--- a/tests/test-subrepo.t	Tue Oct 26 14:41:58 2010 +0300
+++ b/tests/test-subrepo.t	Wed Oct 27 00:28:40 2010 +0200
@@ -636,12 +636,23 @@
   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