httppeer: use try/except/finally
authorMatt Mackall <mpm@selenic.com>
Fri, 15 May 2015 09:57:02 -0500
changeset 25085 e05734cd7902
parent 25084 7046c7e7fcb4
child 25086 140c2d1e57e7
httppeer: use try/except/finally
mercurial/httppeer.py
--- a/mercurial/httppeer.py	Fri May 15 09:56:43 2015 -0500
+++ b/mercurial/httppeer.py	Fri May 15 09:57:02 2015 -0500
@@ -198,16 +198,15 @@
         headers = {'Content-Type': 'application/mercurial-0.1'}
 
         try:
-            try:
-                r = self._call(cmd, data=fp, headers=headers, **args)
-                vals = r.split('\n', 1)
-                if len(vals) < 2:
-                    raise error.ResponseError(_("unexpected response:"), r)
-                return vals
-            except socket.error, err:
-                if err.args[0] in (errno.ECONNRESET, errno.EPIPE):
-                    raise util.Abort(_('push failed: %s') % err.args[1])
-                raise util.Abort(err.args[1])
+            r = self._call(cmd, data=fp, headers=headers, **args)
+            vals = r.split('\n', 1)
+            if len(vals) < 2:
+                raise error.ResponseError(_("unexpected response:"), r)
+            return vals
+        except socket.error, err:
+            if err.args[0] in (errno.ECONNRESET, errno.EPIPE):
+                raise util.Abort(_('push failed: %s') % err.args[1])
+            raise util.Abort(err.args[1])
         finally:
             fp.close()
             os.unlink(tempname)