clonebundle: support bundle2
authorGregory Szorc <gregory.szorc@gmail.com>
Tue, 13 Oct 2015 10:41:54 -0700
changeset 26643 d2e16419d3f4
parent 26642 70ac5f724fbd
child 26644 74de1c59f71c
clonebundle: support bundle2 exchange.readbundle() can return 2 different types. We weren't handling the bundle2 case. Handle it. At some point we'll likely want a generic API for applying a bundle from a file handle. For now, create another one-off until we figure out what the unified bundle API should look like (addressing this is a can of worms I don't want to open right now).
mercurial/exchange.py
tests/test-clonebundles.t
--- a/mercurial/exchange.py	Mon Oct 05 21:31:32 2015 -0700
+++ b/mercurial/exchange.py	Tue Oct 13 10:41:54 2015 -0700
@@ -1653,7 +1653,11 @@
             try:
                 fh = urlmod.open(ui, url)
                 cg = readbundle(ui, fh, 'stream')
-                changegroup.addchangegroup(repo, cg, 'clonebundles', url)
+
+                if isinstance(cg, bundle2.unbundle20):
+                    bundle2.processbundle(repo, cg, lambda: tr)
+                else:
+                    changegroup.addchangegroup(repo, cg, 'clonebundles', url)
                 tr.close()
                 return True
             except urllib2.HTTPError as e:
--- a/tests/test-clonebundles.t	Mon Oct 05 21:31:32 2015 -0700
+++ b/tests/test-clonebundles.t	Tue Oct 13 10:41:54 2015 -0700
@@ -128,7 +128,7 @@
 
 Bundle with full content works
 
-  $ hg -R server bundle --type gzip --base null -r tip full.hg
+  $ hg -R server bundle --type gzip-v2 --base null -r tip full.hg
   2 changesets found
 
   $ echo "http://localhost:$HGPORT1/full.hg" > server/.hg/clonebundles.manifest