# HG changeset patch # User Boris Feld # Date 1513861091 -3600 # Node ID bdae51a83dfb8d2a941ff8945287ba7a182298bc # Parent cf841f2b5a727f3adb90809e67d06de6316ce49f clonebundle: make it possible to retrieve the initial bundle through largefile By setting the default path early enough, we make it possible to retrieve a clone bundle as a largefile from the repository we are cloning. But... why? Clone bundle is a great feature to speeds up clone of large repository. However one of the main obstacle for clone bundle deployment is the authentication scheme. For non public project, just putting a static file on some random CDN is not an option as we have to make sure people have the proper permission to retrieves the bundle. On the other hand, 'largefiles' already have all the necessary logic to serve arbitrary binary files -after- an authentication checks. So reusing an existing large file infrastructure can be a significant shortcut to clone bundle in this kind of closed environment. The idea might seems strange, but the necessary update to the large file extensions are quite small while the benefits are huge. In addition, since all the extra logic live in the 'largefiles' extensions, core does not have to know anything about it. diff -r cf841f2b5a72 -r bdae51a83dfb mercurial/hg.py --- a/mercurial/hg.py Thu Dec 21 13:57:57 2017 +0100 +++ b/mercurial/hg.py Thu Dec 21 13:58:11 2017 +0100 @@ -659,6 +659,9 @@ checkout = revs[0] local = destpeer.local() if local: + u = util.url(abspath) + defaulturl = bytes(u) + local.ui.setconfig('paths', 'default', defaulturl, 'clone') if not stream: if pull: stream = False diff -r cf841f2b5a72 -r bdae51a83dfb tests/test-clonebundles.t --- a/tests/test-clonebundles.t Thu Dec 21 13:57:57 2017 +0100 +++ b/tests/test-clonebundles.t Thu Dec 21 13:58:11 2017 +0100 @@ -517,3 +517,30 @@ transferred 613 bytes in * seconds (*) (glob) searching for changes no changes found + +Test clone bundle retrieved through bundle2 + + $ cat << EOF >> $HGRCPATH + > [extensions] + > largefiles= + > EOF + $ killdaemons.py + $ hg -R server serve -d -p $HGPORT --pid-file hg.pid --accesslog access.log + $ cat hg.pid >> $DAEMON_PIDS + + $ hg -R server debuglfput gz-a.hg + f6eca29e25359f6a92f1ea64527cdcf1b5abe62a + + $ cat > server/.hg/clonebundles.manifest << EOF + > largefile://f6eca29e25359f6a92f1ea64527cdcf1b5abe62a BUNDLESPEC=gzip-v2 + > EOF + + $ hg clone -U http://localhost:$HGPORT largefile-provided --traceback + applying clone bundle from largefile://f6eca29e25359f6a92f1ea64527cdcf1b5abe62a + adding changesets + adding manifests + adding file changes + added 2 changesets with 2 changes to 2 files + finished applying clone bundle + searching for changes + no changes found