[PATCH 1 of 1] subrepo: propagate non-default pull/push path to relative subrepos (issue1852)

Mads Kiilerich mads at kiilerich.com
Mon Oct 18 21:15:38 CDT 2010


# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1287454440 -7200
# Node ID ca2900ed5b79386882401ddb2396428c7e1b9d6e
# Parent  ef5eaf53f4f73ee1e225f5c524cb51ed1e7bb973
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
@@ -2775,7 +2775,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._tmpsubrepotoppath = source
+    try:
+        return postincoming(ui, repo, modheads, opts.get('update'), checkout)
+    finally:
+        del repo._tmpsubrepotoppath
 
 def push(ui, repo, dest=None, **opts):
     """push changes to the specified destination
@@ -2814,13 +2818,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._tmpsubrepotoppath = 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._tmpsubrepotoppath
     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 @@
             else: # plain file system path
                 return posixpath.normpath(os.path.join(parent, repo._subsource))
     else: # recursion reached top repo
+        if hasattr(repo, '_tmpsubrepotoppath'):
+            return repo._tmpsubrepotoppath
         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
@@ -637,12 +637,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


More information about the Mercurial-devel mailing list