Patchwork [3,of,5] largefiles: introduce lfutil.findstorepath()

mail settings
Submitter Matt Harbison
Date April 5, 2015, 2:34 a.m.
Message ID <638946441587a61e3076.1428201261@Envy>
Download mbox | patch
Permalink /patch/8501/
State Accepted
Headers show


Matt Harbison - April 5, 2015, 2:34 a.m.
# HG changeset patch
# User Matt Harbison <>
# Date 1428190300 14400
#      Sat Apr 04 19:31:40 2015 -0400
# Node ID 638946441587a61e307669e61244045916d99d1d
# Parent  35aa561e59e68e951ebac081a9c7f6a5e64b0ace
largefiles: introduce lfutil.findstorepath()

The handful of direct uses of lfutil.storepath() merely need a single path to
read from or write to the largefile, whether or not it exists.  Most callers
that care about the file existing call lfutil.findfile(), in order to fallback
from the store to the user cache.

localstore._verify() doesn't call lfutil.findfile().  This prevents redirecting
the store to the share source because the largefiles for existing repos may not
be in the source's store, so verification may fail.  It can't be changed to call
findfile(), because findfile() links the file from the usercache to the local
store[1], and because it returns None instead of a path if the file doesn't

For now, this method is just a cover for lfutil.storepath(), but it will be
filled out in an upcoming patch.

[1] Maybe we shouldn't care?  But on a filesystem that doesn't support
    hardlinks, then verify will take a lot longer, and start to consume disk


diff --git a/hgext/largefiles/ b/hgext/largefiles/
--- a/hgext/largefiles/
+++ b/hgext/largefiles/
@@ -170,6 +170,13 @@ 
 def storepath(repo, hash):
     return repo.join(longname, hash)
+def findstorepath(repo, hash):
+    '''Search through the local store path(s) to find the file for the given
+    hash.  If the file is not found, its path in the primary store is returned.
+    The return value is a tuple of (path, exists(path)).
+    '''
+    return (storepath(repo, hash), instore(repo, hash))
 def copyfromcache(repo, hash, filename):
     '''Copy the specified largefile from the repo or system cache to
     filename in the repository. Return true on success or false if the