# HG changeset patch # User Mads Kiilerich # Date 2013-01-28 14:19:44 # Node ID d43823f928fedd9387ee9457d01b03a8038cebce # Parent ce5f529deb36b093c5fa35c70ba336b4ce04d07c 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. 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 @@ class remotestore(basestore.basestore): 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 @@ -1574,18 +1574,16 @@ largefiles pulled on update - a largefil $ 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 @@ largefiles pulled on update - a largefil 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/