Show More
@@ -348,8 +348,9 def applybundle(repo, unbundler, tr, sou | |||
|
348 | 348 | return op |
|
349 | 349 | |
|
350 | 350 | class partiterator(object): |
|
351 | def __init__(self, repo, unbundler): | |
|
351 | def __init__(self, repo, op, unbundler): | |
|
352 | 352 | self.repo = repo |
|
353 | self.op = op | |
|
353 | 354 | self.unbundler = unbundler |
|
354 | 355 | self.iterator = None |
|
355 | 356 | self.count = 0 |
@@ -363,10 +364,43 class partiterator(object): | |||
|
363 | 364 | self.iterator = func() |
|
364 | 365 | return self.iterator |
|
365 | 366 | |
|
366 |
def __exit__(self, type, |
|
|
367 | def __exit__(self, type, exc, tb): | |
|
367 | 368 | if not self.iterator: |
|
368 | 369 | return |
|
369 | 370 | |
|
371 | if exc: | |
|
372 | # Any exceptions seeking to the end of the bundle at this point are | |
|
373 | # almost certainly related to the underlying stream being bad. | |
|
374 | # And, chances are that the exception we're handling is related to | |
|
375 | # getting in that bad state. So, we swallow the seeking error and | |
|
376 | # re-raise the original error. | |
|
377 | seekerror = False | |
|
378 | try: | |
|
379 | for part in self.iterator: | |
|
380 | # consume the bundle content | |
|
381 | part.seek(0, 2) | |
|
382 | except Exception: | |
|
383 | seekerror = True | |
|
384 | ||
|
385 | # Small hack to let caller code distinguish exceptions from bundle2 | |
|
386 | # processing from processing the old format. This is mostly needed | |
|
387 | # to handle different return codes to unbundle according to the type | |
|
388 | # of bundle. We should probably clean up or drop this return code | |
|
389 | # craziness in a future version. | |
|
390 | exc.duringunbundle2 = True | |
|
391 | salvaged = [] | |
|
392 | replycaps = None | |
|
393 | if self.op.reply is not None: | |
|
394 | salvaged = self.op.reply.salvageoutput() | |
|
395 | replycaps = self.op.reply.capabilities | |
|
396 | exc._replycaps = replycaps | |
|
397 | exc._bundle2salvagedoutput = salvaged | |
|
398 | ||
|
399 | # Re-raising from a variable loses the original stack. So only use | |
|
400 | # that form if we need to. | |
|
401 | if seekerror: | |
|
402 | raise exc | |
|
403 | ||
|
370 | 404 | self.repo.ui.debug('bundle2-input-bundle: %i parts total\n' % |
|
371 | 405 | self.count) |
|
372 | 406 | |
@@ -402,45 +436,9 def processbundle(repo, unbundler, trans | |||
|
402 | 436 | msg.append('\n') |
|
403 | 437 | repo.ui.debug(''.join(msg)) |
|
404 | 438 | |
|
405 | with partiterator(repo, unbundler) as parts: | |
|
406 | part = None | |
|
407 | try: | |
|
439 | with partiterator(repo, op, unbundler) as parts: | |
|
408 | 440 |
|
|
409 | 441 |
|
|
410 | except Exception as exc: | |
|
411 | # Any exceptions seeking to the end of the bundle at this point are | |
|
412 | # almost certainly related to the underlying stream being bad. | |
|
413 | # And, chances are that the exception we're handling is related to | |
|
414 | # getting in that bad state. So, we swallow the seeking error and | |
|
415 | # re-raise the original error. | |
|
416 | seekerror = False | |
|
417 | try: | |
|
418 | for part in parts: | |
|
419 | # consume the bundle content | |
|
420 | part.seek(0, 2) | |
|
421 | except Exception: | |
|
422 | seekerror = True | |
|
423 | ||
|
424 | # Small hack to let caller code distinguish exceptions from bundle2 | |
|
425 | # processing from processing the old format. This is mostly needed | |
|
426 | # to handle different return codes to unbundle according to the type | |
|
427 | # of bundle. We should probably clean up or drop this return code | |
|
428 | # craziness in a future version. | |
|
429 | exc.duringunbundle2 = True | |
|
430 | salvaged = [] | |
|
431 | replycaps = None | |
|
432 | if op.reply is not None: | |
|
433 | salvaged = op.reply.salvageoutput() | |
|
434 | replycaps = op.reply.capabilities | |
|
435 | exc._replycaps = replycaps | |
|
436 | exc._bundle2salvagedoutput = salvaged | |
|
437 | ||
|
438 | # Re-raising from a variable loses the original stack. So only use | |
|
439 | # that form if we need to. | |
|
440 | if seekerror: | |
|
441 | raise exc | |
|
442 | else: | |
|
443 | raise | |
|
444 | 442 | |
|
445 | 443 | return op |
|
446 | 444 |
General Comments 0
You need to be logged in to leave comments.
Login now