enhance the error output in case of failure during http push
authorBenoit Boissinot <benoit.boissinot@ens-lyon.org>
Mon, 08 Sep 2008 14:22:14 +0200
changeset 7010 9141bebefe3e
parent 7009 3d54cf97598d
child 7011 7da76778dbd7
enhance the error output in case of failure during http push
mercurial/httprepo.py
--- a/mercurial/httprepo.py	Mon Sep 08 14:04:10 2008 +0200
+++ b/mercurial/httprepo.py	Mon Sep 08 14:22:14 2008 +0200
@@ -422,16 +422,18 @@
         fp = httpsendfile(tempname, "rb")
         try:
             try:
-                rfp = self.do_cmd(
-                    'unbundle', data=fp,
-                    headers={'Content-Type': 'application/octet-stream'},
-                    heads=' '.join(map(hex, heads)))
+                resp = self.do_read(
+                     'unbundle', data=fp,
+                     headers={'Content-Type': 'application/octet-stream'},
+                     heads=' '.join(map(hex, heads)))
+                resp_code, output = resp.split('\n', 1)
                 try:
-                    ret = int(rfp.readline())
-                    self.ui.write(rfp.read())
-                    return ret
-                finally:
-                    rfp.close()
+                    ret = int(resp_code)
+                except ValueError, err:
+                    raise util.UnexpectedOutput(
+                            _('push failed (unexpected response):'), resp)
+                self.ui.write(output)
+                return ret
             except socket.error, err:
                 if err[0] in (errno.ECONNRESET, errno.EPIPE):
                     raise util.Abort(_('push failed: %s') % err[1])