infinitepush: handle old changegroup format correctly server-side

Summary:
`exchange.readbundle()` can return bundle2 unbundler or changegroup cg1unpacker.
In case of cg1unpacker let's just read it from the stream

Test Plan: arc unit

Reviewers: #mercurial, quark

Reviewed By: quark

Subscribers: quark, mjpieters, #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D4913313

Tasks: 15389402

Signature: t1:4913313:1492623174:72abe4d1e449ae31d78a6c98b554c0406e8a2ea2
This commit is contained in:
Stanislau Hlebik 2017-04-20 07:30:51 -07:00
parent 1aed2e20f9
commit da24919aa2

View File

@ -471,10 +471,17 @@ def getbundlechunks(orig, repo, source, heads=None, bundlecaps=None, **kwargs):
if not _needsrebundling(head, bundlerepo):
with util.posixfile(bundlefile, "rb") as f:
unbundler = exchange.readbundle(repo.ui, f, bundlefile)
for part in unbundler.iterparts():
if part.type == 'changegroup':
version = part.params.get('version', '01')
scratchbundles.append((part.read(), version))
if isinstance(unbundler, changegroup.cg1unpacker):
scratchbundles.append((unbundler._stream.read(),
'01'))
elif isinstance(unbundler, bundle2.unbundle20):
for part in unbundler.iterparts():
if part.type == 'changegroup':
version = part.params.get('version', '01')
scratchbundles.append(
(part.read(), version))
else:
raise error.Abort('unknown bundle type')
else:
outputbundleraw = _rebundle(bundlerepo, bundleroots,
head, version='02')