largefiles: adapt remotestore._getfile to batched statlfile stable
authorMads Kiilerich <madski@unity3d.com>
Mon, 28 Jan 2013 15:19:44 +0100
branchstable
changeset 18484 d43823f928fe
parent 18483 ce5f529deb36
child 18485 39cecda9ff77
largefiles: adapt 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. This makes the code work as intended ... but it would probably be better if it didn't abort on missing largefiles, just like it happened to do before.
hgext/largefiles/remotestore.py
tests/test-largefiles.t
--- a/hgext/largefiles/remotestore.py	Mon Jan 28 15:19:44 2013 +0100
+++ b/hgext/largefiles/remotestore.py	Mon Jan 28 15:19:44 2013 +0100
@@ -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)
--- a/tests/test-largefiles.t	Mon Jan 28 15:19:44 2013 +0100
+++ b/tests/test-largefiles.t	Mon Jan 28 15:19:44 2013 +0100
@@ -1574,18 +1574,16 @@
   $ mv empty/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90 .
   $ hg -R http-clone up --config largefiles.usercache=http-clone-usercache
   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]
   $ hg -R http-clone up -Cqr null
 
 largefiles pulled on update - a largefile corrupted on the server:
   $ echo corruption > empty/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90
   $ hg -R http-clone up --config largefiles.usercache=http-clone-usercache
   getting changed largefiles
-  f1: data corruption (expected 02a439e5c31c526465ab1a0ca1f431f76b827b90, got 6a7bb2556144babe3899b25e5428123735bb1e27)
-  0 largefiles updated, 0 removed
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  abort: remotestore: largefile 02a439e5c31c526465ab1a0ca1f431f76b827b90 is invalid
+  [255]
   $ hg -R http-clone st
   ! f1
   $ [ ! -f http-clone/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90 ]
@@ -1602,7 +1600,6 @@
   verified contents of 1 revisions of 1 largefiles
   [1]
   $ hg -R http-clone up -Cqr null
-  $ rm http-clone/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90
 
 largefiles pulled on update - no server side problems:
   $ mv 02a439e5c31c526465ab1a0ca1f431f76b827b90 empty/.hg/largefiles/