Patchwork [7,of,8,stream,clone,bundles,V2] exchange: support streaming clone bundles in clone bundles

login
register
mail settings
Submitter Gregory Szorc
Date Oct. 17, 2015, 6:45 p.m.
Message ID <f275023580fd45caaa55.1445107503@126.1.168.192.in-addr.arpa>
Download mbox | patch
Permalink /patch/11167/
State Accepted
Headers show

Comments

Gregory Szorc - Oct. 17, 2015, 6:45 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1445107028 25200
#      Sat Oct 17 11:37:08 2015 -0700
# Node ID f275023580fd45caaa553626f1478c50c58f1fc7
# Parent  85a8854e4f52539cde2a15a0edc9bb423e53003d
exchange: support streaming clone bundles in clone bundles

Now that we have support for detecting compatible stream clone bundles
in bundle specifications, we can safely add support for applying stream
clone bundles to the clone bundles feature.

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1831,8 +1831,10 @@  def trypullbundlefromurl(ui, repo, url):
                 cg = readbundle(ui, fh, 'stream')
 
                 if isinstance(cg, bundle2.unbundle20):
                     bundle2.processbundle(repo, cg, lambda: tr)
+                elif isinstance(cg, streamclone.streamcloneapplier):
+                    cg.apply(repo)
                 else:
                     cg.apply(repo, 'clonebundles', url)
                 tr.close()
                 return True
diff --git a/tests/test-clonebundles.t b/tests/test-clonebundles.t
--- a/tests/test-clonebundles.t
+++ b/tests/test-clonebundles.t
@@ -272,8 +272,71 @@  Python <2.7.9 will filter SNI URLs
   searching for changes
   no changes found
 #endif
 
+Stream clone bundles are supported
+
+  $ hg -R server debugcreatestreamclonebundle packed.hg
+  writing 613 bytes for 4 files
+  bundle requirements: revlogv1
+
+No bundle spec should work
+
+  $ cat > server/.hg/clonebundles.manifest << EOF
+  > http://localhost:$HGPORT1/packed.hg
+  > EOF
+
+  $ hg clone -U http://localhost:$HGPORT stream-clone-no-spec
+  applying clone bundle from http://localhost:$HGPORT1/packed.hg
+  4 files to transfer, 613 bytes of data
+  transferred 613 bytes in *.* seconds (*) (glob)
+  finished applying clone bundle
+  searching for changes
+  no changes found
+
+Bundle spec without parameters should work
+
+  $ cat > server/.hg/clonebundles.manifest << EOF
+  > http://localhost:$HGPORT1/packed.hg BUNDLESPEC=none-packed1
+  > EOF
+
+  $ hg clone -U http://localhost:$HGPORT stream-clone-vanilla-spec
+  applying clone bundle from http://localhost:$HGPORT1/packed.hg
+  4 files to transfer, 613 bytes of data
+  transferred 613 bytes in *.* seconds (*) (glob)
+  finished applying clone bundle
+  searching for changes
+  no changes found
+
+Bundle spec with format requirements should work
+
+  $ cat > server/.hg/clonebundles.manifest << EOF
+  > http://localhost:$HGPORT1/packed.hg BUNDLESPEC=none-packed1;requirements%3Drevlogv1
+  > EOF
+
+  $ hg clone -U http://localhost:$HGPORT stream-clone-supported-requirements
+  applying clone bundle from http://localhost:$HGPORT1/packed.hg
+  4 files to transfer, 613 bytes of data
+  transferred 613 bytes in *.* seconds (*) (glob)
+  finished applying clone bundle
+  searching for changes
+  no changes found
+
+Stream bundle spec with unknown requirements should be filtered out
+
+  $ cat > server/.hg/clonebundles.manifest << EOF
+  > http://localhost:$HGPORT1/packed.hg BUNDLESPEC=none-packed1;requirements%3Drevlogv42
+  > EOF
+
+  $ hg clone -U http://localhost:$HGPORT stream-clone-unsupported-requirements
+  no compatible clone bundles available on server; falling back to regular clone
+  (you may want to report this to the server operator)
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 2 changes to 2 files
+
 Set up manifest for testing preferences
 (Remember, the TYPE does not have to match reality - the URL is
 important)