Patchwork [01,of,12,stable] bundle2: decorate exception raised during bundle processing

login
register
mail settings
Submitter Pierre-Yves David
Date April 22, 2014, 8:10 p.m.
Message ID <be776cb2751748613018.1398197445@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/4420/
State Accepted
Commit 70fcb0a714457662421baf3f3dfbcbcb2f25620e
Headers show

Comments

Pierre-Yves David - April 22, 2014, 8:10 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1398190961 25200
#      Tue Apr 22 11:22:41 2014 -0700
# Branch stable
# Node ID be776cb27517486130180fa9d7abdd9f20fdff84
# Parent  bf28918773785705bb4197899dec139513ff470c
bundle2: decorate exception raised during bundle processing

This is a small hack to helpuse doing some graceful error handling in bundle2
without major refactoring. See embedded comment for details.

Patch

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -321,17 +321,23 @@  def processbundle(repo, unbundler, trans
                                      advisoryparams=[('in-reply-to',
                                                       str(part.id))],
                                      data=output)
                 op.reply.addpart(outpart)
             part.read()
-    except Exception:
+    except Exception, exc:
         if part is not None:
             # consume the bundle content
             part.read()
         for part in iterparts:
             # consume the bundle content
             part.read()
+        # Small hack to let caller code distincting exception from bundle2
+        # processing fron the ones from bundle1 processing. This is mostly
+        # needed to handle different return code to unbundle according to the
+        # type of bundle. We should probably clean up or drop this return code
+        # crazyness in future version.
+        exc.duringunbundle2 = True
         raise
     return op
 
 def decodecaps(blob):
     """decode a bundle2 caps bytes blob into a dictionnary