Show More
@@ -521,6 +521,10 b' class unpackermixin(object):' | |||
|
521 | 521 | if util.safehasattr(self._fp, 'close'): |
|
522 | 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 | 528 | class unbundle20(unpackermixin): |
|
525 | 529 | """interpret a bundle2 stream |
|
526 | 530 |
@@ -33,7 +33,7 b' def readbundle(ui, fh, fname, vfs=None):' | |||
|
33 | 33 | alg = changegroup.readexactly(fh, 2) |
|
34 | 34 | return changegroup.cg1unpacker(fh, alg) |
|
35 | 35 | elif version == '2Y': |
|
36 |
return bundle2.unbundle |
|
|
36 | return bundle2.getunbundler(ui, fh, header=magic + version) | |
|
37 | 37 | else: |
|
38 | 38 | raise util.Abort(_('%s: unknown bundle version %s') % (fname, version)) |
|
39 | 39 |
@@ -114,7 +114,7 b' class localpeer(peer.peerrepository):' | |||
|
114 | 114 | # When requesting a bundle2, getbundle returns a stream to make the |
|
115 | 115 | # wire level function happier. We need to build a proper object |
|
116 | 116 | # from it in local peer. |
|
117 |
cg = bundle2.unbundle |
|
|
117 | cg = bundle2.getunbundler(self.ui, cg) | |
|
118 | 118 | return cg |
|
119 | 119 | |
|
120 | 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 | 132 | # This little dance should be dropped eventually when the API |
|
133 | 133 | # is finally improved. |
|
134 | 134 | stream = util.chunkbuffer(ret.getchunks()) |
|
135 |
ret = bundle2.unbundle |
|
|
135 | ret = bundle2.getunbundler(self.ui, stream) | |
|
136 | 136 | return ret |
|
137 | 137 | except error.PushRaced, exc: |
|
138 | 138 | raise error.ResponseError(_('push failed:'), str(exc)) |
@@ -364,7 +364,7 b' class wirepeer(peer.peerrepository):' | |||
|
364 | 364 | f = self._callcompressable("getbundle", **opts) |
|
365 | 365 | bundlecaps = kwargs.get('bundlecaps') |
|
366 | 366 | if bundlecaps is not None and 'HG2Y' in bundlecaps: |
|
367 |
return bundle2.unbundle |
|
|
367 | return bundle2.getunbundler(self.ui, f) | |
|
368 | 368 | else: |
|
369 | 369 | return changegroupmod.cg1unpacker(f, 'UN') |
|
370 | 370 | |
@@ -401,7 +401,7 b' class wirepeer(peer.peerrepository):' | |||
|
401 | 401 | else: |
|
402 | 402 | # bundle2 push. Send a stream, fetch a stream. |
|
403 | 403 | stream = self._calltwowaystream('unbundle', cg, heads=heads) |
|
404 |
ret = bundle2.unbundle |
|
|
404 | ret = bundle2.getunbundler(self.ui, stream) | |
|
405 | 405 | return ret |
|
406 | 406 | |
|
407 | 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 | 157 | > lock = repo.lock() |
|
158 | 158 | > tr = repo.transaction('processbundle') |
|
159 | 159 | > try: |
|
160 |
> unbundler = bundle2.unbundle |
|
|
160 | > unbundler = bundle2.getunbundler(ui, sys.stdin) | |
|
161 | 161 | > op = bundle2.processbundle(repo, unbundler, lambda: tr) |
|
162 | 162 | > tr.close() |
|
163 | 163 | > except error.BundleValueError, exc: |
@@ -183,7 +183,7 b' Create an extension to test bundle2 API' | |||
|
183 | 183 | > @command('statbundle2', [], '') |
|
184 | 184 | > def cmdstatbundle2(ui, repo): |
|
185 | 185 | > """print statistic on the bundle2 container read from stdin""" |
|
186 |
> unbundler = bundle2.unbundle |
|
|
186 | > unbundler = bundle2.getunbundler(ui, sys.stdin) | |
|
187 | 187 | > try: |
|
188 | 188 | > params = unbundler.params |
|
189 | 189 | > except error.BundleValueError, exc: |
General Comments 0
You need to be logged in to leave comments.
Login now