diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py --- a/hgext/largefiles/lfutil.py +++ b/hgext/largefiles/lfutil.py @@ -82,9 +82,10 @@ def inusercache(ui, hash): return path and os.path.exists(path) def findfile(repo, hash): - if instore(repo, hash): + path, exists = findstorepath(repo, hash) + if exists: repo.ui.note(_('found %s in store\n') % hash) - return storepath(repo, hash) + return path elif inusercache(repo.ui, hash): repo.ui.note(_('found %s in system cache\n') % hash) path = storepath(repo, hash) @@ -164,10 +165,12 @@ def listlfiles(repo, rev=None, matcher=N for f in repo[rev].walk(matcher) if rev is not None or repo.dirstate[f] != '?'] -def instore(repo, hash): - return os.path.exists(storepath(repo, hash)) +def instore(repo, hash, forcelocal=False): + return os.path.exists(storepath(repo, hash, forcelocal)) -def storepath(repo, hash): +def storepath(repo, hash, forcelocal=False): + if not forcelocal and repo.shared(): + return repo.vfs.reljoin(repo.sharedpath, longname, hash) return repo.join(longname, hash) def findstorepath(repo, hash): @@ -175,7 +178,17 @@ def findstorepath(repo, hash): 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)) + # For shared repos, the primary store is in the share source. But for + # backward compatibility, force a lookup in the local store if it wasn't + # found in the share source. + path = storepath(repo, hash, False) + + if instore(repo, hash): + return (path, True) + elif repo.shared() and instore(repo, hash, True): + return storepath(repo, hash, True) + + return (path, False) def copyfromcache(repo, hash, filename): '''Copy the specified largefile from the repo or system cache to diff --git a/tests/test-largefiles-cache.t b/tests/test-largefiles-cache.t --- a/tests/test-largefiles-cache.t +++ b/tests/test-largefiles-cache.t @@ -153,3 +153,29 @@ for a forget.) ENOENT: * (glob) not removing z: file is already untracked [1] + +Largefiles are accessible from the share's store + $ cd .. + $ hg share -q src share_dst --config extensions.share= + $ hg -R share_dst update -r0 + getting changed largefiles + 1 largefiles updated, 0 removed + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + + $ echo modified > share_dst/large + $ hg -R share_dst ci -m modified + created new head + +Only dirstate is in the local store for the share, and the largefile is in the +share source's local store. Avoid the extra largefiles added in the unix +conditional above. + $ hash=`hg -R share_dst cat share_dst/.hglf/large` + $ echo $hash + e2fb5f2139d086ded2cb600d5a91a196e76bf020 + + $ find share_dst/.hg/largefiles/* | sort + share_dst/.hg/largefiles/dirstate + + $ find src/.hg/largefiles/* | egrep "(dirstate|$hash)" | sort + src/.hg/largefiles/dirstate + src/.hg/largefiles/e2fb5f2139d086ded2cb600d5a91a196e76bf020