comparison mercurial/localrepo.py @ 24641:60fecc5b14a4

unbundle20: retrieve unbundler instances through a factory function To support multiple bundle2 formats, we will need a function returning the proper unbundler according to the header. We introduce such aa function and change the usage in the code base. The function will get smarter in later changesets. This is somewhat similar to the dispatching we do for 'HG10' and 'HG11'. The main target is to allow HG2Y support in an extension to ease transition of companies using the experimental protocol in production (yeah...) But I've no doubt this will be useful when playing with a future HG21.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Mon, 06 Apr 2015 16:04:33 -0700
parents c79b1e690110
children e0e28e910fa3
comparison
equal deleted inserted replaced
24640:685639f9430d 24641:60fecc5b14a4
112 common=common, bundlecaps=bundlecaps, **kwargs) 112 common=common, bundlecaps=bundlecaps, **kwargs)
113 if bundlecaps is not None and 'HG2Y' in bundlecaps: 113 if bundlecaps is not None and 'HG2Y' in bundlecaps:
114 # When requesting a bundle2, getbundle returns a stream to make the 114 # When requesting a bundle2, getbundle returns a stream to make the
115 # wire level function happier. We need to build a proper object 115 # wire level function happier. We need to build a proper object
116 # from it in local peer. 116 # from it in local peer.
117 cg = bundle2.unbundle20(self.ui, cg) 117 cg = bundle2.getunbundler(self.ui, cg)
118 return cg 118 return cg
119 119
120 # TODO We might want to move the next two calls into legacypeer and add 120 # TODO We might want to move the next two calls into legacypeer and add
121 # unbundle instead. 121 # unbundle instead.
122 122
130 if util.safehasattr(ret, 'getchunks'): 130 if util.safehasattr(ret, 'getchunks'):
131 # This is a bundle20 object, turn it into an unbundler. 131 # This is a bundle20 object, turn it into an unbundler.
132 # This little dance should be dropped eventually when the API 132 # This little dance should be dropped eventually when the API
133 # is finally improved. 133 # is finally improved.
134 stream = util.chunkbuffer(ret.getchunks()) 134 stream = util.chunkbuffer(ret.getchunks())
135 ret = bundle2.unbundle20(self.ui, stream) 135 ret = bundle2.getunbundler(self.ui, stream)
136 return ret 136 return ret
137 except error.PushRaced, exc: 137 except error.PushRaced, exc:
138 raise error.ResponseError(_('push failed:'), str(exc)) 138 raise error.ResponseError(_('push failed:'), str(exc))
139 139
140 def lock(self): 140 def lock(self):