Patchwork [6,of,7] bundle2: add on more layer of exception catching in localrepo.unbundle

login
register
mail settings
Submitter Pierre-Yves David
Date April 16, 2015, 9:25 a.m.
Message ID <14b4d54ac72d694498c8.1429176348@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/8708/
State Accepted
Headers show

Comments

Pierre-Yves David - April 16, 2015, 9:25 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1429175377 14400
#      Thu Apr 16 05:09:37 2015 -0400
# Node ID 14b4d54ac72d694498c899df4fd180d144fcac7f
# Parent  dd5533374a6c23410d2f0fc3b3b46c61bebe7894
bundle2: add on more layer of exception catching in localrepo.unbundle

We are going to add output related logic in this function. We do the
indentation first to help next changeset readability. We need a new try except
because we want to handle output on any exception, including PushRaced ones.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -123,19 +123,22 @@  class localpeer(peer.peerrepository):
     def unbundle(self, cg, heads, url):
         """apply a bundle on a repo
 
         This function handles the repo locking itself."""
         try:
-            cg = exchange.readbundle(self.ui, cg, None)
-            ret = exchange.unbundle(self._repo, cg, heads, 'push', url)
-            if util.safehasattr(ret, 'getchunks'):
-                # This is a bundle20 object, turn it into an unbundler.
-                # This little dance should be dropped eventually when the API
-                # is finally improved.
-                stream = util.chunkbuffer(ret.getchunks())
-                ret = bundle2.getunbundler(self.ui, stream)
-            return ret
+            try:
+                cg = exchange.readbundle(self.ui, cg, None)
+                ret = exchange.unbundle(self._repo, cg, heads, 'push', url)
+                if util.safehasattr(ret, 'getchunks'):
+                    # This is a bundle20 object, turn it into an unbundler.
+                    # This little dance should be dropped eventually when the
+                    # API is finally improved.
+                    stream = util.chunkbuffer(ret.getchunks())
+                    ret = bundle2.getunbundler(self.ui, stream)
+                return ret
+            except Exception, exc:
+                raise
         except error.PushRaced, exc:
             raise error.ResponseError(_('push failed:'), str(exc))
 
     def lock(self):
         return self._repo.lock()