comparison 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
comparison
equal deleted inserted replaced
21067:7974aa88868e 21068:c15b66a6bbb4
7 from node import hex, nullid, short 7 from node import hex, nullid, short
8 from i18n import _ 8 from i18n import _
9 import peer, changegroup, subrepo, pushkey, obsolete, repoview 9 import peer, changegroup, subrepo, pushkey, obsolete, repoview
10 import changelog, dirstate, filelog, manifest, context, bookmarks, phases 10 import changelog, dirstate, filelog, manifest, context, bookmarks, phases
11 import lock as lockmod 11 import lock as lockmod
12 import transaction, store, encoding, exchange 12 import transaction, store, encoding, exchange, bundle2
13 import scmutil, util, extensions, hook, error, revset 13 import scmutil, util, extensions, hook, error, revset
14 import match as matchmod 14 import match as matchmod
15 import merge as mergemod 15 import merge as mergemod
16 import tags as tagsmod 16 import tags as tagsmod
17 from lock import release 17 from lock import release
104 def known(self, nodes): 104 def known(self, nodes):
105 return self._repo.known(nodes) 105 return self._repo.known(nodes)
106 106
107 def getbundle(self, source, heads=None, common=None, bundlecaps=None, 107 def getbundle(self, source, heads=None, common=None, bundlecaps=None,
108 format='HG10'): 108 format='HG10'):
109 return exchange.getbundle(self._repo, source, heads=heads, 109 cg = exchange.getbundle(self._repo, source, heads=heads,
110 common=common, bundlecaps=bundlecaps) 110 common=common, bundlecaps=bundlecaps)
111 if bundlecaps is not None and 'HG20' in bundlecaps:
112 # When requesting a bundle2, getbundle returns a stream to make the
113 # wire level function happier. We need to build a proper object
114 # from it in local peer.
115 cg = bundle2.unbundle20(self.ui, cg)
116 return cg
111 117
112 # TODO We might want to move the next two calls into legacypeer and add 118 # TODO We might want to move the next two calls into legacypeer and add
113 # unbundle instead. 119 # unbundle instead.
114 120
115 def unbundle(self, cg, heads, url): 121 def unbundle(self, cg, heads, url):