##// END OF EJS Templates
unbundle20: retrieve unbundler instances through a factory function...
Pierre-Yves David -
r24641:60fecc5b default
parent child Browse files
Show More
@@ -521,6 +521,10 b' class unpackermixin(object):'
521 if util.safehasattr(self._fp, 'close'):
521 if util.safehasattr(self._fp, 'close'):
522 return self._fp.close()
522 return self._fp.close()
523
523
524 def getunbundler(ui, fp, header=None):
525 """return a valid unbundler object for a given header"""
526 return unbundle20(ui, fp, header)
527
524 class unbundle20(unpackermixin):
528 class unbundle20(unpackermixin):
525 """interpret a bundle2 stream
529 """interpret a bundle2 stream
526
530
@@ -33,7 +33,7 b' def readbundle(ui, fh, fname, vfs=None):'
33 alg = changegroup.readexactly(fh, 2)
33 alg = changegroup.readexactly(fh, 2)
34 return changegroup.cg1unpacker(fh, alg)
34 return changegroup.cg1unpacker(fh, alg)
35 elif version == '2Y':
35 elif version == '2Y':
36 return bundle2.unbundle20(ui, fh, header=magic + version)
36 return bundle2.getunbundler(ui, fh, header=magic + version)
37 else:
37 else:
38 raise util.Abort(_('%s: unknown bundle version %s') % (fname, version))
38 raise util.Abort(_('%s: unknown bundle version %s') % (fname, version))
39
39
@@ -114,7 +114,7 b' class localpeer(peer.peerrepository):'
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
@@ -132,7 +132,7 b' class localpeer(peer.peerrepository):'
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))
@@ -364,7 +364,7 b' class wirepeer(peer.peerrepository):'
364 f = self._callcompressable("getbundle", **opts)
364 f = self._callcompressable("getbundle", **opts)
365 bundlecaps = kwargs.get('bundlecaps')
365 bundlecaps = kwargs.get('bundlecaps')
366 if bundlecaps is not None and 'HG2Y' in bundlecaps:
366 if bundlecaps is not None and 'HG2Y' in bundlecaps:
367 return bundle2.unbundle20(self.ui, f)
367 return bundle2.getunbundler(self.ui, f)
368 else:
368 else:
369 return changegroupmod.cg1unpacker(f, 'UN')
369 return changegroupmod.cg1unpacker(f, 'UN')
370
370
@@ -401,7 +401,7 b' class wirepeer(peer.peerrepository):'
401 else:
401 else:
402 # bundle2 push. Send a stream, fetch a stream.
402 # bundle2 push. Send a stream, fetch a stream.
403 stream = self._calltwowaystream('unbundle', cg, heads=heads)
403 stream = self._calltwowaystream('unbundle', cg, heads=heads)
404 ret = bundle2.unbundle20(self.ui, stream)
404 ret = bundle2.getunbundler(self.ui, stream)
405 return ret
405 return ret
406
406
407 def debugwireargs(self, one, two, three=None, four=None, five=None):
407 def debugwireargs(self, one, two, three=None, four=None, five=None):
@@ -157,7 +157,7 b' Create an extension to test bundle2 API'
157 > lock = repo.lock()
157 > lock = repo.lock()
158 > tr = repo.transaction('processbundle')
158 > tr = repo.transaction('processbundle')
159 > try:
159 > try:
160 > unbundler = bundle2.unbundle20(ui, sys.stdin)
160 > unbundler = bundle2.getunbundler(ui, sys.stdin)
161 > op = bundle2.processbundle(repo, unbundler, lambda: tr)
161 > op = bundle2.processbundle(repo, unbundler, lambda: tr)
162 > tr.close()
162 > tr.close()
163 > except error.BundleValueError, exc:
163 > except error.BundleValueError, exc:
@@ -183,7 +183,7 b' Create an extension to test bundle2 API'
183 > @command('statbundle2', [], '')
183 > @command('statbundle2', [], '')
184 > def cmdstatbundle2(ui, repo):
184 > def cmdstatbundle2(ui, repo):
185 > """print statistic on the bundle2 container read from stdin"""
185 > """print statistic on the bundle2 container read from stdin"""
186 > unbundler = bundle2.unbundle20(ui, sys.stdin)
186 > unbundler = bundle2.getunbundler(ui, sys.stdin)
187 > try:
187 > try:
188 > params = unbundler.params
188 > params = unbundler.params
189 > except error.BundleValueError, exc:
189 > except error.BundleValueError, exc:
General Comments 0
You need to be logged in to leave comments. Login now