352 nbpart = 0 |
352 nbpart = 0 |
353 try: |
353 try: |
354 for nbpart, part in iterparts: |
354 for nbpart, part in iterparts: |
355 _processpart(op, part) |
355 _processpart(op, part) |
356 except Exception as exc: |
356 except Exception as exc: |
357 for nbpart, part in iterparts: |
357 # Any exceptions seeking to the end of the bundle at this point are |
358 # consume the bundle content |
358 # almost certainly related to the underlying stream being bad. |
359 part.seek(0, 2) |
359 # And, chances are that the exception we're handling is related to |
|
360 # getting in that bad state. So, we swallow the seeking error and |
|
361 # re-raise the original error. |
|
362 seekerror = False |
|
363 try: |
|
364 for nbpart, part in iterparts: |
|
365 # consume the bundle content |
|
366 part.seek(0, 2) |
|
367 except Exception: |
|
368 seekerror = True |
|
369 |
360 # Small hack to let caller code distinguish exceptions from bundle2 |
370 # Small hack to let caller code distinguish exceptions from bundle2 |
361 # processing from processing the old format. This is mostly |
371 # processing from processing the old format. This is mostly |
362 # needed to handle different return codes to unbundle according to the |
372 # needed to handle different return codes to unbundle according to the |
363 # type of bundle. We should probably clean up or drop this return code |
373 # type of bundle. We should probably clean up or drop this return code |
364 # craziness in a future version. |
374 # craziness in a future version. |
368 if op.reply is not None: |
378 if op.reply is not None: |
369 salvaged = op.reply.salvageoutput() |
379 salvaged = op.reply.salvageoutput() |
370 replycaps = op.reply.capabilities |
380 replycaps = op.reply.capabilities |
371 exc._replycaps = replycaps |
381 exc._replycaps = replycaps |
372 exc._bundle2salvagedoutput = salvaged |
382 exc._bundle2salvagedoutput = salvaged |
373 raise |
383 |
|
384 # Re-raising from a variable loses the original stack. So only use |
|
385 # that form if we need to. |
|
386 if seekerror: |
|
387 raise exc |
|
388 else: |
|
389 raise |
374 finally: |
390 finally: |
375 repo.ui.debug('bundle2-input-bundle: %i parts total\n' % nbpart) |
391 repo.ui.debug('bundle2-input-bundle: %i parts total\n' % nbpart) |
376 |
392 |
377 return op |
393 return op |
378 |
394 |