# HG changeset patch # User Matt Mackall # Date 2015-05-15 14:57:02 # Node ID e05734cd7902d8b709fbf120433a8846d7e747e9 # Parent 7046c7e7fcb4d044b072a225b62797bd89a98170 httppeer: use try/except/finally diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py --- a/mercurial/httppeer.py +++ b/mercurial/httppeer.py @@ -198,16 +198,15 @@ class httppeer(wireproto.wirepeer): 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)