Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/bundlerepo.py @ 35136:2b72bc88043f
bundle2: only seek to beginning of part in bundlerepo
For reasons still not yet fully understood by me, bundlerepo
requires its changegroup bundle2 part to be seeked to beginning
after part iteration. As far as I can tell, it is the only
bundle2 part consumer that relies on this behavior.
This seeking was performed in the generic iterparts() API. Again,
I don't fully understand why it was here and not in bundlerepo.
Probably historical reasons.
What I do know is that all other bundle2 part consumers don't
need this special behavior (assuming the tests are comprehensive).
So, we move the code from bundle2's iterparts() to bundlerepo's
consumption of iterparts().
Differential Revision: https://phab.mercurial-scm.org/D1389
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 13 Nov 2017 20:12:00 -0800 |
parents | cd4cd7b94ff1 |
children | da91e7309daf |
comparison
equal
deleted
inserted
replaced
35135:db5038525718 | 35136:2b72bc88043f |
---|---|
286 | 286 |
287 if isinstance(bundle, bundle2.unbundle20): | 287 if isinstance(bundle, bundle2.unbundle20): |
288 self._bundlefile = bundle | 288 self._bundlefile = bundle |
289 self._cgunpacker = None | 289 self._cgunpacker = None |
290 | 290 |
291 hadchangegroup = False | 291 cgpart = None |
292 for part in bundle.iterparts(): | 292 for part in bundle.iterparts(): |
293 if part.type == 'changegroup': | 293 if part.type == 'changegroup': |
294 if hadchangegroup: | 294 if cgpart: |
295 raise NotImplementedError("can't process " | 295 raise NotImplementedError("can't process " |
296 "multiple changegroups") | 296 "multiple changegroups") |
297 hadchangegroup = True | 297 cgpart = part |
298 | 298 |
299 self._handlebundle2part(bundle, part) | 299 self._handlebundle2part(bundle, part) |
300 | 300 |
301 if not hadchangegroup: | 301 if not cgpart: |
302 raise error.Abort(_("No changegroups found")) | 302 raise error.Abort(_("No changegroups found")) |
303 | |
304 # This is required to placate a later consumer, which expects | |
305 # the payload offset to be at the beginning of the changegroup. | |
306 # We need to do this after the iterparts() generator advances | |
307 # because iterparts() will seek to end of payload after the | |
308 # generator returns control to iterparts(). | |
309 cgpart.seek(0, os.SEEK_SET) | |
310 | |
303 elif isinstance(bundle, changegroup.cg1unpacker): | 311 elif isinstance(bundle, changegroup.cg1unpacker): |
304 if bundle.compressed(): | 312 if bundle.compressed(): |
305 f = self._writetempbundle(bundle.read, '.hg10un', | 313 f = self._writetempbundle(bundle.read, '.hg10un', |
306 header='HG10UN') | 314 header='HG10UN') |
307 bundle = exchange.readbundle(ui, f, bundlepath, self.vfs) | 315 bundle = exchange.readbundle(ui, f, bundlepath, self.vfs) |