##// END OF EJS Templates
bundle2: extract processing of part into its own function...
Pierre-Yves David -
r23008:d3137827 default
parent child Browse files
Show More
@@ -292,6 +292,26 b' def processbundle(repo, unbundler, trans'
292 part = None
292 part = None
293 try:
293 try:
294 for part in iterparts:
294 for part in iterparts:
295 _processpart(op, part)
296 except Exception, exc:
297 for part in iterparts:
298 # consume the bundle content
299 part.read()
300 # Small hack to let caller code distinguish exceptions from bundle2
301 # processing fron the ones from bundle1 processing. This is mostly
302 # needed to handle different return codes to unbundle according to the
303 # type of bundle. We should probably clean up or drop this return code
304 # craziness in a future version.
305 exc.duringunbundle2 = True
306 raise
307 return op
308
309 def _processpart(op, part):
310 """process a single part from a bundle
311
312 The part is guaranteed to have been fully consumed when the function exits
313 (even if an exception is raised)."""
314 try:
295 parttype = part.type
315 parttype = part.type
296 # part key are matched lower case
316 # part key are matched lower case
297 key = parttype.lower()
317 key = parttype.lower()
@@ -310,10 +330,7 b' def processbundle(repo, unbundler, trans'
310 if key != parttype: # mandatory parts
330 if key != parttype: # mandatory parts
311 raise
331 raise
312 op.ui.debug('ignoring unsupported advisory part %s\n' % exc)
332 op.ui.debug('ignoring unsupported advisory part %s\n' % exc)
313 # consuming the part
333 return # skip to part processing
314 part.read()
315 continue
316
317
334
318 # handler is called outside the above try block so that we don't
335 # handler is called outside the above try block so that we don't
319 # risk catching KeyErrors from anything other than the
336 # risk catching KeyErrors from anything other than the
@@ -331,22 +348,10 b' def processbundle(repo, unbundler, trans'
331 if output:
348 if output:
332 outpart = op.reply.newpart('b2x:output', data=output)
349 outpart = op.reply.newpart('b2x:output', data=output)
333 outpart.addparam('in-reply-to', str(part.id), mandatory=False)
350 outpart.addparam('in-reply-to', str(part.id), mandatory=False)
334 part.read()
351 finally:
335 except Exception, exc:
352 # consume the part content to not corrupt the stream.
336 if part is not None:
337 # consume the bundle content
338 part.read()
339 for part in iterparts:
340 # consume the bundle content
341 part.read()
353 part.read()
342 # Small hack to let caller code distinguish exceptions from bundle2
354
343 # processing fron the ones from bundle1 processing. This is mostly
344 # needed to handle different return codes to unbundle according to the
345 # type of bundle. We should probably clean up or drop this return code
346 # craziness in a future version.
347 exc.duringunbundle2 = True
348 raise
349 return op
350
355
351 def decodecaps(blob):
356 def decodecaps(blob):
352 """decode a bundle2 caps bytes blob into a dictionnary
357 """decode a bundle2 caps bytes blob into a dictionnary
General Comments 0
You need to be logged in to leave comments. Login now