Patchwork [03,of,10,stable] largefiles: adopt remotestore._getfile to batched statlfile

login
register
mail settings
Submitter Mads Kiilerich
Date Jan. 25, 2013, 5:17 a.m.
Message ID <7d7317f017caeeada050.1359091022@mk-desktop>
Download mbox | patch
Permalink /patch/725/
State Deferred, archived
Headers show

Comments

Mads Kiilerich - Jan. 25, 2013, 5:17 a.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1359090858 -3600
# Branch stable
# Node ID 7d7317f017caeeada0501bbf18bc8f9bc6b15650
# Parent  d956326990d42e04627d0d8077380c6f69921132
largefiles: adopt remotestore._getfile to batched statlfile

9e1616307c4c introduced batching of statlfile, but not all codepaths got
converted.

_getfile gave _stat garbage and got garbage back. The garbage didn't match the
expected error codes and was thus interpreted as success. It could thus end up
trying to fetch a largefile that didn't exist.

Instead we now pass _stat valid input and handle both correct and invalid
output correctly.

Patch

diff --git a/hgext/largefiles/remotestore.py b/hgext/largefiles/remotestore.py
--- a/hgext/largefiles/remotestore.py
+++ b/hgext/largefiles/remotestore.py
@@ -48,11 +48,14 @@ 
 
     def _getfile(self, tmpfile, filename, hash):
         # quit if the largefile isn't there
-        stat = self._stat(hash)
+        stat = self._stat([hash])[hash]
         if stat == 1:
             raise util.Abort(_('remotestore: largefile %s is invalid') % hash)
         elif stat == 2:
             raise util.Abort(_('remotestore: largefile %s is missing') % hash)
+        elif stat != 0:
+            raise RuntimeError('error getting file: unexpected response from '
+                               'statlfile (%r)' % stat)
 
         try:
             length, infile = self._get(hash)
diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t
--- a/tests/test-largefiles.t
+++ b/tests/test-largefiles.t
@@ -1600,9 +1600,8 @@ 
 try again and expect error
   $ hg -R http-clone up
   getting changed largefiles
-  error getting id 02a439e5c31c526465ab1a0ca1f431f76b827b90 from url http://localhost:$HGPORT2/ for file f1: HTTP Error 500: Internal Server Error
-  0 largefiles updated, 0 removed
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  abort: remotestore: largefile 02a439e5c31c526465ab1a0ca1f431f76b827b90 is missing
+  [255]
 
   $ rm -rf empty http-clone http-clone-usercache