changeset 36688:fb278041df06 stable

subrepo: activate clone pooling to enable sharing with remote URLs This is the easiest way to ensure that repositories with remote subrepo references can share the subrepos, consistent with how local subrepos can be shared.
author Matt Harbison <matt_harbison@yahoo.com>
date Thu, 01 Mar 2018 11:37:00 -0500
parents eed02e192770
children b394778b1a50
files mercurial/subrepo.py tests/test-subrepo-recursion.t tests/test-subrepo-relative-path.t
diffstat 3 files changed, 37 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/subrepo.py	Thu Mar 01 11:13:00 2018 -0500
+++ b/mercurial/subrepo.py	Thu Mar 01 11:37:00 2018 -0500
@@ -996,11 +996,25 @@
                                   update=False, bookmarks=False)
                 self._repo = shared.local()
             else:
+                # TODO: find a common place for this and this code in the
+                # share.py wrap of the clone command.
+                if parentrepo.shared():
+                    pool = self.ui.config('share', 'pool')
+                    if pool:
+                        pool = util.expandpath(pool)
+
+                    shareopts = {
+                        'pool': pool,
+                        'mode': self.ui.config('share', 'poolnaming'),
+                    }
+                else:
+                    shareopts = {}
+
                 self.ui.status(_('cloning subrepo %s from %s\n')
                                % (subrelpath(self), srcurl))
                 other, cloned = hg.clone(self._repo._subparent.baseui, {},
                                          other, self._repo.root,
-                                         update=False)
+                                         update=False, shareopts=shareopts)
                 self._repo = cloned.local()
             self._initrepo(parentrepo, source, create=True)
             self._cachestorehash(srcurl)
--- a/tests/test-subrepo-recursion.t	Thu Mar 01 11:13:00 2018 -0500
+++ b/tests/test-subrepo-recursion.t	Thu Mar 01 11:37:00 2018 -0500
@@ -292,8 +292,8 @@
   z2
   z3
 
-BUG: The remote subrepo should be cloned to the local pool, and then shared
-from there.
+Clone pooling from a remote URL will share the top level repo and the subrepos,
+even if they are referenced by remote URL.
 
   $ hg --config extensions.share= --config share.pool=$TESTTMP/pool \
   >    clone http://localhost:$HGPORT shared
@@ -308,19 +308,25 @@
   no changes found
   updating working directory
   cloning subrepo foo from http://localhost:$HGPORT/foo
+  (sharing from new pooled repository af048e97ade2e236f754f05d07013e586af0f8bf)
   requesting all changes
   adding changesets
   adding manifests
   adding file changes
   added 4 changesets with 7 changes to 3 files
   new changesets af048e97ade2:65903cebad86
+  searching for changes
+  no changes found
   cloning subrepo foo/bar from http://localhost:$HGPORT/foo/bar
+  (sharing from new pooled repository 4904098473f96c900fec436dad267edd4da59fad)
   requesting all changes
   adding changesets
   adding manifests
   adding file changes
   added 3 changesets with 3 changes to 1 files
   new changesets 4904098473f9:31ecbdafd357
+  searching for changes
+  no changes found
   3 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
   $ cat access.log
@@ -341,11 +347,19 @@
   $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=lookup HTTP/1.1" 200 - x-hgarg-1:key=0 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?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D65903cebad86f1a84bd4f1134f62fa7dcb7a1c98 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=0&common=65903cebad86f1a84bd4f1134f62fa7dcb7a1c98&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=lookup HTTP/1.1" 200 - x-hgarg-1:key=0 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)
+  $LOCALIP - - [$LOGDATE$] "GET /foo/bar?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D31ecbdafd357f54b281c9bd1d681bb90de219e22 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=0&common=31ecbdafd357f54b281c9bd1d681bb90de219e22&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	Thu Mar 01 11:13:00 2018 -0500
+++ b/tests/test-subrepo-relative-path.t	Thu Mar 01 11:37:00 2018 -0500
@@ -84,9 +84,9 @@
   adding .hgsub
   $ cd ..
 
-Clone pooling works for local clones with a remote subrepo reference.
-
-BUG: subrepos should be shared out of the pool.
+Clone pooling works for local clones with a remote subrepo reference.  The
+subrepo is cloned to the pool and shared from there, so that all clones will
+share the same subrepo.
 
   $ hg --config extensions.share= --config share.pool=$TESTTMP/pool \
   >    clone absolute_subrepo cloned_from_abs
@@ -101,12 +101,15 @@
   no changes found
   updating working directory
   cloning subrepo sub from http://localhost:$HGPORT/sub
+  (sharing from new pooled repository 863c1745b441bd97a8c4a096e87793073f4fb215)
   requesting all changes
   adding changesets
   adding manifests
   adding file changes
   added 1 changesets with 1 changes to 1 files
   new changesets 863c1745b441
+  searching for changes
+  no changes found
   3 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 Vanilla sharing with a subrepo remote path reference will clone the subrepo.