# HG changeset patch # User Gregory Szorc # Date 2015-10-13 17:41:54 # Node ID d2e16419d3f4c11ccf757d10cf2fffb152f9c036 # Parent 70ac5f724fbdc3b86de8e7d3e854e1045c672f60 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 @@ -1653,7 +1653,11 @@ def trypullbundlefromurl(ui, repo, url): 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: diff --git a/tests/test-clonebundles.t b/tests/test-clonebundles.t --- a/tests/test-clonebundles.t +++ b/tests/test-clonebundles.t @@ -128,7 +128,7 @@ Bundle with partial content works 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