[PATCH 2 of 2] bundle2: transmit exception during part generation

Augie Fackler raf at durin42.com
Wed Oct 22 10:02:50 CDT 2014


On Oct 21, 2014, at 11:03 PM, Pierre-Yves David <pierre-yves.david at ens-lyon.org> wrote:

> 
> 
> On 10/21/2014 10:41 PM, Augie Fackler wrote:
>> On Tue, Oct 21, 2014 at 01:08:46PM -0700, Pierre-Yves David wrote:
>>> # HG changeset patch
>>> # User Pierre-Yves David <pierre-yves.david at fb.com>
>>> # Date 1413370340 25200
>>> #      Wed Oct 15 03:52:20 2014 -0700
>>> # Branch stable
>>> # Node ID bd35fb4708eda7d548a34ef6ff504505cf0e85cb
>>> # Parent  1c1b98ea77615d601d8234f70728da9a21692c93
>>> bundle2: transmit exception during part generation
>>> 
>>> If an exception is raised during a bundle2 part payload generation it is now
>>> recorded in the bundle. If such exception occurs, we capture it, transmit an
>>> abort exception through the bundle, cleanly close the current part payload and
>>> raise it again. This allow to generate valid bundle even in case of exception so
>>> that the consumer does not wait forever for a dead producer. This also allow to
>>> raise the exception during unbundling at the exact point it happened during
>>> bundling make debugging easier.
>>> 
>>> diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
>>> --- a/mercurial/bundle2.py
>>> +++ b/mercurial/bundle2.py
>>> @@ -143,10 +143,11 @@ process is aborted, the full bundle is s
>>>  channel usable. But none of the part read from an abort are processed. In the
>>>  future, dropping the stream may become an option for channel we do not care to
>>>  preserve.
>>>  """
>>> 
>>> +import sys
>>>  import util
>>>  import struct
>>>  import urllib
>>>  import string
>>>  import obsolete
>>> @@ -671,13 +672,26 @@ class bundlepart(object):
>>>          ## finalize header
>>>          headerchunk = ''.join(header)
>>>          yield _pack(_fpartheadersize, len(headerchunk))
>>>          yield headerchunk
>>>          ## payload
>>> -        for chunk in self._payloadchunks():
>>> -            yield _pack(_fpayloadsize, len(chunk))
>>> -            yield chunk
>>> +        try:
>>> +            for chunk in self._payloadchunks():
>>> +                yield _pack(_fpayloadsize, len(chunk))
>>> +                yield chunk
>>> +        except Exception:
>>> +            # backup exception data for later
>>> +            exc_info = sys.exc_info()
>>> +            msg = 'unexpected error: %s' % exc
>> 
>> exc isn't defined here - did you mean exc_info, or did you want to
>> catch the exception as exc?
> 
> actually msg is not used. Drop the line.

It appears to be on the next line - it looks like you meant to catch Exception as exc, so I've done that and will push soon.

> 
> -- 
> Pierre-Yves David

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20141022/59b152fd/attachment.html>


More information about the Mercurial-devel mailing list