largefiles: prevent committing a missing largefile stable
authorMatt Harbison <>
Sun, 24 Jan 2016 00:10:19 -0500
changeset 29896 571ba161f6be9ad696efcdbcf8bdf0a8a6ba0766
parent 29895 ca8d2b73155d30d7402391cb48ab6727cd33f9e7
child 29897 7cb7264cfd52d2672644db4bc16a0bd50aa093ca
push id175
push dateWed, 10 Feb 2016 01:24:28 +0000
largefiles: prevent committing a missing largefile Previously, if the largefile was deleted at the time of a commit, the standin was silently not updated and its current state (possibly garbage) was recorded. The test makes it look like this is somewhat of an edge case, but the same thing happens when an `hg revert` followed by `rm` changes the standin. Aside from the second invocation of this in lfutil.updatestandinsbymatch() (which is what triggers this test case), the three other uses are guarded by dirstate checks for added or modified, or an existence check in the filesystem. So aborting in lfutil.updatestandins() should be safe, and will avoid silent skips in the future if this is used elsewhere.
--- a/hgext/largefiles/
+++ b/hgext/largefiles/
@@ -314,16 +314,18 @@ def splitstandin(filename):
         return None
 def updatestandin(repo, standin):
     file = repo.wjoin(splitstandin(standin))
     if os.path.exists(file):
         hash = hashfile(file)
         executable = getexecutable(file)
         writestandin(repo, standin, hash, executable)
+    else:
+        raise error.Abort(_('%s: file not found!') % splitstandin(standin))
 def readstandin(repo, filename, node=None):
     '''read hex hash from standin for filename at given node, or working
     directory if no node is given'''
     return repo[node][standin(filename)].data().strip()
 def writestandin(repo, standin, hash, executable):
     '''write hash to <repo.root>/<standin>'''
--- a/tests/test-largefiles-cache.t
+++ b/tests/test-largefiles-cache.t
@@ -14,16 +14,22 @@ Create source repo, and commit adding la
   $ hg init src
   $ cd src
   $ echo large > large
   $ hg add --large large
   $ hg commit -m 'add largefile'
   $ hg rm large
   $ hg commit -m 'branchhead without largefile' large
   $ hg up -qr 0
+  $ rm large
+  $ echo "0000000000000000000000000000000000000000" > .hglf/large
+  $ hg commit -m 'commit missing file with corrupt standin' large
+  abort: large: file not found!
+  [255]
+  $ hg up -Cqr 0
   $ cd ..
 Discard all cached largefiles in USERCACHE
   $ rm -rf ${USERCACHE}
 Create mirror repo, and pull from source without largefile:
 "pull" is used instead of "clone" for suppression of (1) updating to