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).
--- 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