Mercurial > hg
changeset 39483:1fc39367eafd
httppeer: calculate total expected bytes correctly
User-facing error messages that handled httplib.IncompleteRead errors in
Mercurial used to look like this:
abort: HTTP request error (incomplete response; expected 3 bytes got 1)
But the errors that are being handled underneath the UI look like this:
IncompleteRead(1 bytes read, 3 more expected)
I.e. the error actually counts total number of expected bytes minus bytes
already received.
Before, users could see weird messages like "expected 10 bytes got 10", while
in reality httplib expected 10 _more_ bytes (20 in total).
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Sat, 08 Sep 2018 23:57:07 +0800 |
parents | 77a2f6d805f2 |
children | 98995b689e03 |
files | mercurial/httppeer.py tests/test-http-bad-server.t |
diffstat | 2 files changed, 8 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/httppeer.py Fri Sep 07 23:36:09 2018 -0700 +++ b/mercurial/httppeer.py Sat Sep 08 23:57:07 2018 +0800 @@ -84,9 +84,10 @@ except httplib.IncompleteRead as e: # e.expected is an integer if length known or None otherwise. if e.expected: + got = len(e.partial) + total = e.expected + got msg = _('HTTP request error (incomplete response; ' - 'expected %d bytes got %d)') % (e.expected, - len(e.partial)) + 'expected %d bytes got %d)') % (total, got) else: msg = _('HTTP request error (incomplete response)')
--- a/tests/test-http-bad-server.t Fri Sep 07 23:36:09 2018 -0700 +++ b/tests/test-http-bad-server.t Sat Sep 08 23:57:07 2018 +0800 @@ -275,7 +275,7 @@ $ cat hg.pid > $DAEMON_PIDS $ hg clone http://localhost:$HGPORT/ clone - abort: HTTP request error (incomplete response; expected 416 bytes got 20) + abort: HTTP request error (incomplete response; expected 436 bytes got 20) (this may be an intermittent network failure; if the error persists, consider contacting the network or server operator) [255] @@ -600,7 +600,7 @@ $ hg clone http://localhost:$HGPORT/ clone requesting all changes - abort: HTTP request error (incomplete response; expected 1 bytes got 3) + abort: HTTP request error (incomplete response; expected 4 bytes got 3) (this may be an intermittent network failure; if the error persists, consider contacting the network or server operator) [255] @@ -624,7 +624,7 @@ $ hg clone http://localhost:$HGPORT/ clone requesting all changes - abort: HTTP request error (incomplete response; expected 1 bytes got 3) + abort: HTTP request error (incomplete response; expected 4 bytes got 3) (this may be an intermittent network failure; if the error persists, consider contacting the network or server operator) [255] @@ -733,7 +733,7 @@ adding changesets transaction abort! rollback completed - abort: HTTP request error (incomplete response; expected 459 bytes got 7) + abort: HTTP request error (incomplete response; expected 466 bytes got 7) (this may be an intermittent network failure; if the error persists, consider contacting the network or server operator) [255] @@ -799,7 +799,7 @@ added 1 changesets with 1 changes to 1 files transaction abort! rollback completed - abort: HTTP request error (incomplete response; expected 23 bytes got 9) + abort: HTTP request error (incomplete response; expected 32 bytes got 9) (this may be an intermittent network failure; if the error persists, consider contacting the network or server operator) [255]