Patchwork [4,of,4,stable,v2] largefiles: don't mute and obfuscate http errors when putlfile fails

login
register
mail settings
Submitter Mads Kiilerich
Date Oct. 23, 2015, 7:27 p.m.
Message ID <337963d5562974410828.1445628478@localhost.localdomain>
Download mbox | patch
Permalink /patch/11223/
State Accepted
Headers show

Comments

Mads Kiilerich - Oct. 23, 2015, 7:27 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1445628449 -7200
#      Fri Oct 23 21:27:29 2015 +0200
# Branch stable
# Node ID 337963d5562974410828623133f669b0fcaaadea
# Parent  b8280810816ec6d2512681c249f825a48af0b0bc
largefiles: don't mute and obfuscate http errors when putlfile fails

'unexpected putlfile response: None' when an http error occurs is not very
helpful.

Instead, leave the handling of urllib2.HTTPError exceptions to other layers.
Matt Mackall - Oct. 23, 2015, 7:49 p.m.
On Fri, 2015-10-23 at 21:27 +0200, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1445628449 -7200
> #      Fri Oct 23 21:27:29 2015 +0200
> # Branch stable
> # Node ID 337963d5562974410828623133f669b0fcaaadea
> # Parent  b8280810816ec6d2512681c249f825a48af0b0bc
> largefiles: don't mute and obfuscate http errors when putlfile fails

These are queued for stable, thanks.

-- 
Mathematics is the supreme nostalgia of our time.

Patch

diff --git a/hgext/largefiles/proto.py b/hgext/largefiles/proto.py
--- a/hgext/largefiles/proto.py
+++ b/hgext/largefiles/proto.py
@@ -86,15 +86,14 @@  def wirereposetup(ui, repo):
             # input file-like into a bundle before sending it, so we can't use
             # it ...
             if issubclass(self.__class__, httppeer.httppeer):
-                res = None
+                res = self._call('putlfile', data=fd, sha=sha,
+                    headers={'content-type':'application/mercurial-0.1'})
                 try:
-                    res = self._call('putlfile', data=fd, sha=sha,
-                        headers={'content-type':'application/mercurial-0.1'})
                     d, output = res.split('\n', 1)
                     for l in output.splitlines(True):
                         self.ui.warn(_('remote: '), l) # assume l ends with \n
                     return int(d)
-                except (ValueError, urllib2.HTTPError):
+                except ValueError:
                     self.ui.warn(_('unexpected putlfile response: %r\n') % res)
                     return 1
             # ... but we can't use sshrepository._call because the data=
diff --git a/tests/test-largefiles-cache.t b/tests/test-largefiles-cache.t
--- a/tests/test-largefiles-cache.t
+++ b/tests/test-largefiles-cache.t
@@ -209,12 +209,10 @@  Test coverage of error handling from put
   $ hg serve -R ../mirror -d -p $HGPORT1 --pid-file hg.pid --config largefiles.usercache=$TESTTMP/mirrorcache
   $ cat hg.pid >> $DAEMON_PIDS
 
-(the following push fails but doesn't show why)
   $ hg push http://localhost:$HGPORT1 -f --config files.usercache=nocache
   pushing to http://localhost:$HGPORT1/
   searching for changes
-  unexpected putlfile response: None
-  abort: remotestore: could not put $TESTTMP/src/.hg/largefiles/e2fb5f2139d086ded2cb600d5a91a196e76bf020 to remote store http://localhost:$HGPORT1/
+  abort: remotestore: could not open file $TESTTMP/src/.hg/largefiles/e2fb5f2139d086ded2cb600d5a91a196e76bf020: HTTP Error 403: ssl required
   [255]
 
   $ rm .hg/largefiles/e2fb5f2139d086ded2cb600d5a91a196e76bf020