Mercurial > hg
comparison mercurial/bundle2.py @ 21176:70fcb0a71445 stable
bundle2: decorate exception raised during bundle processing
This is a small hack to help us do some graceful error handling in bundle2
without major refactoring. See embedded comment for details.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Tue, 22 Apr 2014 11:22:41 -0700 |
parents | 4676135ac555 |
children | 952af771bc17 |
comparison
equal
deleted
inserted
replaced
21175:dae36d3e1c60 | 21176:70fcb0a71445 |
---|---|
321 advisoryparams=[('in-reply-to', | 321 advisoryparams=[('in-reply-to', |
322 str(part.id))], | 322 str(part.id))], |
323 data=output) | 323 data=output) |
324 op.reply.addpart(outpart) | 324 op.reply.addpart(outpart) |
325 part.read() | 325 part.read() |
326 except Exception: | 326 except Exception, exc: |
327 if part is not None: | 327 if part is not None: |
328 # consume the bundle content | 328 # consume the bundle content |
329 part.read() | 329 part.read() |
330 for part in iterparts: | 330 for part in iterparts: |
331 # consume the bundle content | 331 # consume the bundle content |
332 part.read() | 332 part.read() |
333 # Small hack to let caller code distinguish exceptions from bundle2 | |
334 # processing fron the ones from bundle1 processing. This is mostly | |
335 # needed to handle different return codes to unbundle according to the | |
336 # type of bundle. We should probably clean up or drop this return code | |
337 # craziness in a future version. | |
338 exc.duringunbundle2 = True | |
333 raise | 339 raise |
334 return op | 340 return op |
335 | 341 |
336 def decodecaps(blob): | 342 def decodecaps(blob): |
337 """decode a bundle2 caps bytes blob into a dictionnary | 343 """decode a bundle2 caps bytes blob into a dictionnary |