Mercurial > hg-stable
comparison mercurial/bundle2.py @ 24794:21f2e8f48ae1
bundle2: add a 'salvageoutput' method on bundle20
This method returns a copy of all 'output' parts added to the bundler.
This is the second step in our quest for preserving the server output on error
(issue4594). We want to be able to copy the output parts from the aborted reply
into the exception bundle.
The function will be used in a later patch.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Thu, 16 Apr 2015 03:16:04 -0400 |
parents | 2ec894582ea2 |
children | f9aa4cb8f2dd |
comparison
equal
deleted
inserted
replaced
24793:2ec894582ea2 | 24794:21f2e8f48ae1 |
---|---|
477 if value is not None: | 477 if value is not None: |
478 value = urllib.quote(value) | 478 value = urllib.quote(value) |
479 par = '%s=%s' % (par, value) | 479 par = '%s=%s' % (par, value) |
480 blocks.append(par) | 480 blocks.append(par) |
481 return ' '.join(blocks) | 481 return ' '.join(blocks) |
482 | |
483 def salvageoutput(self): | |
484 """return a list with a copy of all output parts in the bundle | |
485 | |
486 This is meant to be used during error handling to make sure we preserve | |
487 server output""" | |
488 salvaged = [] | |
489 for part in self._parts: | |
490 if part.type.startswith('output'): | |
491 salvaged.append(part.copy()) | |
492 return salvaged | |
493 | |
482 | 494 |
483 class unpackermixin(object): | 495 class unpackermixin(object): |
484 """A mixin to extract bytes and struct data from a stream""" | 496 """A mixin to extract bytes and struct data from a stream""" |
485 | 497 |
486 def __init__(self, fp): | 498 def __init__(self, fp): |