Mercurial > public > mercurial-scm > hg
diff mercurial/localrepo.py @ 21068:c15b66a6bbb4
bundle2: return a stream from exchange.getbundle
For friendliness with the wire protocol implementation, the `exchange.getbundle` now
returns a binary stream when asked for a bundle2. We detect a bundle2 request and
upgrade the binary stream to an unbundler object.
In the future the unbundler may gain feature to look like a binary stream, but
we are not quite there yet.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Tue, 15 Apr 2014 11:27:55 -0400 |
parents | 6c383c871fdb |
children | 408877d491fb |
line wrap: on
line diff
--- a/mercurial/localrepo.py Tue Apr 15 13:57:15 2014 -0400 +++ b/mercurial/localrepo.py Tue Apr 15 11:27:55 2014 -0400 @@ -9,7 +9,7 @@ import peer, changegroup, subrepo, pushkey, obsolete, repoview import changelog, dirstate, filelog, manifest, context, bookmarks, phases import lock as lockmod -import transaction, store, encoding, exchange +import transaction, store, encoding, exchange, bundle2 import scmutil, util, extensions, hook, error, revset import match as matchmod import merge as mergemod @@ -106,8 +106,14 @@ def getbundle(self, source, heads=None, common=None, bundlecaps=None, format='HG10'): - return exchange.getbundle(self._repo, source, heads=heads, - common=common, bundlecaps=bundlecaps) + cg = exchange.getbundle(self._repo, source, heads=heads, + common=common, bundlecaps=bundlecaps) + if bundlecaps is not None and 'HG20' in bundlecaps: + # When requesting a bundle2, getbundle returns a stream to make the + # wire level function happier. We need to build a proper object + # from it in local peer. + cg = bundle2.unbundle20(self.ui, cg) + return cg # TODO We might want to move the next two calls into legacypeer and add # unbundle instead.