changeset 36687:eed02e192770 stable

subrepo: don't attempt to share remote sources (issue5793) Untangling _abssource() to resolve the new subrepo relative to the shared parent's share path, and then either sharing from there (if it exists), or cloning to that location and then sharing, is probably more than should be attempted on stable. Absolute subrepo references are discouraged, so for now, this resumes the behavior prior to 68e0bcb90357 of cloning the absolute subrepo locally.
author Matt Harbison <matt_harbison@yahoo.com>
date Thu, 01 Mar 2018 11:13:00 -0500
parents 0c14b3f23294
children fb278041df06
files mercurial/subrepo.py tests/test-subrepo-recursion.t tests/test-subrepo-relative-path.t
diffstat 3 files changed, 67 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/subrepo.py	Wed Feb 28 00:29:27 2018 -0500
+++ b/mercurial/subrepo.py	Thu Mar 01 11:13:00 2018 -0500
@@ -982,7 +982,13 @@
         if len(self._repo) == 0:
             # use self._repo.vfs instead of self.wvfs to remove .hg only
             self._repo.vfs.rmtree()
-            if parentrepo.shared():
+
+            # A remote subrepo could be shared if there is a local copy
+            # relative to the parent's share source.  But clone pooling doesn't
+            # assemble the repos in a tree, so that can't be consistently done.
+            # A simpler option is for the user to configure clone pooling, and
+            # work with that.
+            if parentrepo.shared() and hg.islocal(srcurl):
                 self.ui.status(_('sharing subrepo %s from %s\n')
                                % (subrelpath(self), srcurl))
                 shared = hg.share(self._repo._subparent.baseui,
--- a/tests/test-subrepo-recursion.t	Wed Feb 28 00:29:27 2018 -0500
+++ b/tests/test-subrepo-recursion.t	Thu Mar 01 11:13:00 2018 -0500
@@ -307,9 +307,21 @@
   searching for changes
   no changes found
   updating working directory
-  sharing subrepo foo from http://localhost:$HGPORT/foo
-  abort: can only share local repositories (in subrepository "foo")
-  [255]
+  cloning subrepo foo from http://localhost:$HGPORT/foo
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 4 changesets with 7 changes to 3 files
+  new changesets af048e97ade2:65903cebad86
+  cloning subrepo foo/bar from http://localhost:$HGPORT/foo/bar
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 3 changesets with 3 changes to 1 files
+  new changesets 4904098473f9:31ecbdafd357
+  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
   $ cat access.log
   * "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
@@ -329,6 +341,11 @@
   $LOCALIP - - [$LOGDATE$] "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D1326fa26d0c00d2146c63b56bb6a45149d7325ac x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ (glob)
   $LOCALIP - - [$LOGDATE$] "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bookmarks=1&$USUAL_BUNDLE_CAPS$&cg=0&common=1326fa26d0c00d2146c63b56bb6a45149d7325ac&heads=1326fa26d0c00d2146c63b56bb6a45149d7325ac&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ (glob)
   $LOCALIP - - [$LOGDATE$] "GET /foo?cmd=capabilities HTTP/1.1" 200 - (glob)
+  $LOCALIP - - [$LOGDATE$] "GET /foo?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ (glob)
+  $LOCALIP - - [$LOGDATE$] "GET /foo?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bookmarks=1&$USUAL_BUNDLE_CAPS$&cg=1&common=0000000000000000000000000000000000000000&heads=65903cebad86f1a84bd4f1134f62fa7dcb7a1c98&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ (glob)
+  $LOCALIP - - [$LOGDATE$] "GET /foo/bar?cmd=capabilities HTTP/1.1" 200 - (glob)
+  $LOCALIP - - [$LOGDATE$] "GET /foo/bar?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ (glob)
+  $LOCALIP - - [$LOGDATE$] "GET /foo/bar?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bookmarks=1&$USUAL_BUNDLE_CAPS$&cg=1&common=0000000000000000000000000000000000000000&heads=31ecbdafd357f54b281c9bd1d681bb90de219e22&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ (glob)
 
   $ killdaemons.py
   $ rm hg1.pid error.log access.log
--- a/tests/test-subrepo-relative-path.t	Wed Feb 28 00:29:27 2018 -0500
+++ b/tests/test-subrepo-relative-path.t	Thu Mar 01 11:13:00 2018 -0500
@@ -84,8 +84,9 @@
   adding .hgsub
   $ cd ..
 
-BUG: Remote subrepos cannot be shared, and pooled repos don't have their
-relative subrepos in the relative location stated in .hgsub.
+Clone pooling works for local clones with a remote subrepo reference.
+
+BUG: subrepos should be shared out of the pool.
 
   $ hg --config extensions.share= --config share.pool=$TESTTMP/pool \
   >    clone absolute_subrepo cloned_from_abs
@@ -99,31 +100,55 @@
   searching for changes
   no changes found
   updating working directory
-  sharing subrepo sub from http://localhost:$HGPORT/sub
-  abort: can only share local repositories (in subrepository "sub")
-  [255]
+  cloning subrepo sub from http://localhost:$HGPORT/sub
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  new changesets 863c1745b441
+  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+Vanilla sharing with a subrepo remote path reference will clone the subrepo.
+Each share of these top level repos will end up with independent subrepo copies
+(potentially leaving the shared parent with dangling cset references).
 
   $ hg --config extensions.share= share absolute_subrepo shared_from_abs
   updating working directory
-  sharing subrepo sub from http://localhost:$HGPORT/sub
-  abort: can only share local repositories (in subrepository "sub")
-  [255]
+  cloning subrepo sub from http://localhost:$HGPORT/sub
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  new changesets 863c1745b441
+  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
   $ hg --config extensions.share= share -U absolute_subrepo shared_from_abs2
   $ hg -R shared_from_abs2 update -r tip
-  sharing subrepo sub from http://localhost:$HGPORT/sub
-  abort: can only share local repositories (in subrepository "sub")
-  [255]
+  cloning subrepo sub from http://localhost:$HGPORT/sub
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  new changesets 863c1745b441
+  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
-BUG: A repo without its subrepo available locally should be sharable if the
+A parent repo without its subrepo available locally can be shared if the
 subrepo is referenced by absolute path.
 
   $ hg clone -U absolute_subrepo cloned_null_from_abs
   $ hg --config extensions.share= share cloned_null_from_abs shared_from_null_abs
   updating working directory
-  sharing subrepo sub from http://localhost:$HGPORT/sub
-  abort: can only share local repositories (in subrepository "sub")
-  [255]
+  cloning subrepo sub from http://localhost:$HGPORT/sub
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  new changesets 863c1745b441
+  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
   $ killdaemons.py