diff --git a/mercurial/keepalive.py b/mercurial/keepalive.py --- a/mercurial/keepalive.py +++ b/mercurial/keepalive.py @@ -90,6 +90,7 @@ import sys import threading +from .i18n import _ from . import ( util, ) @@ -231,6 +232,10 @@ self._cm.add(host, h, 0) self._start_transaction(h, req) r = h.getresponse() + # The string form of BadStatusLine is the status line. Add some context + # to make the error message slightly more useful. + except httplib.BadStatusLine as err: + raise urlerr.urlerror(_('bad HTTP status line: %s') % err.line) except (socket.error, httplib.HTTPException) as err: raise urlerr.urlerror(err) diff --git a/tests/test-http-bad-server.t b/tests/test-http-bad-server.t --- a/tests/test-http-bad-server.t +++ b/tests/test-http-bad-server.t @@ -68,10 +68,8 @@ $ hg --config badserver.closeafterrecvbytes=1 serve -p $HGPORT -d --pid-file=hg.pid -E error.log $ cat hg.pid > $DAEMON_PIDS -TODO this error message is not very good - $ hg clone http://localhost:$HGPORT/ clone - abort: error: '' + abort: error: bad HTTP status line: '' [255] $ killdaemons.py $DAEMON_PIDS @@ -87,7 +85,7 @@ $ hg --config badserver.closeafterrecvbytes=40 serve -p $HGPORT -d --pid-file=hg.pid -E error.log $ cat hg.pid > $DAEMON_PIDS $ hg clone http://localhost:$HGPORT/ clone - abort: error: '' + abort: error: bad HTTP status line: '' [255] $ killdaemons.py $DAEMON_PIDS @@ -104,7 +102,7 @@ $ hg --config badserver.closeafterrecvbytes=210 serve -p $HGPORT -d --pid-file=hg.pid -E error.log $ cat hg.pid > $DAEMON_PIDS $ hg clone http://localhost:$HGPORT/ clone - abort: error: '' + abort: error: bad HTTP status line: '' [255] $ killdaemons.py $DAEMON_PIDS @@ -143,7 +141,7 @@ $ cat hg.pid > $DAEMON_PIDS $ hg clone http://localhost:$HGPORT/ clone requesting all changes - abort: error: '' + abort: error: bad HTTP status line: '' [255] $ killdaemons.py $DAEMON_PIDS @@ -200,7 +198,7 @@ $ cat hg.pid > $DAEMON_PIDS $ hg clone http://localhost:$HGPORT/ clone - abort: error: '' + abort: error: bad HTTP status line: '' [255] $ killdaemons.py $DAEMON_PIDS @@ -251,7 +249,7 @@ $ cat hg.pid > $DAEMON_PIDS $ hg clone http://localhost:$HGPORT/ clone - abort: error: H + abort: error: bad HTTP status line: H [255] $ killdaemons.py $DAEMON_PIDS