[PATCH 3 of 5 clonebundles V3] clonebundle: support bundle2
Gregory Szorc
gregory.szorc at gmail.com
Tue Oct 13 13:54:08 CDT 2015
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1444758114 25200
# Tue Oct 13 10:41:54 2015 -0700
# Node ID 2d1cf61c7beca610a09ab49a8fdd2f56db5e7d23
# Parent 770e985c4dd0e46deebcdeecf74f75f2351b86b1
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).
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1652,9 +1652,13 @@ def trypullbundlefromurl(ui, repo, url):
try:
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:
ui.warn(_('HTTP error fetching bundle: %s\n') % str(e))
diff --git a/tests/test-clonebundles.t b/tests/test-clonebundles.t
--- a/tests/test-clonebundles.t
+++ b/tests/test-clonebundles.t
@@ -127,9 +127,9 @@ Bundle with partial content works
added 1 changesets with 1 changes to 1 files
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
$ hg clone -U http://localhost:$HGPORT full-bundle
More information about the Mercurial-devel
mailing list