##// END OF EJS Templates
largefiles: use the share source as the primary local store (issue4471)...
Matt Harbison -
r24631:2a3f2478 default
parent child Browse files
Show More
@@ -82,9 +82,10 b' def inusercache(ui, hash):'
82 return path and os.path.exists(path)
82 return path and os.path.exists(path)
83
83
84 def findfile(repo, hash):
84 def findfile(repo, hash):
85 if instore(repo, hash):
85 path, exists = findstorepath(repo, hash)
86 if exists:
86 repo.ui.note(_('found %s in store\n') % hash)
87 repo.ui.note(_('found %s in store\n') % hash)
87 return storepath(repo, hash)
88 return path
88 elif inusercache(repo.ui, hash):
89 elif inusercache(repo.ui, hash):
89 repo.ui.note(_('found %s in system cache\n') % hash)
90 repo.ui.note(_('found %s in system cache\n') % hash)
90 path = storepath(repo, hash)
91 path = storepath(repo, hash)
@@ -164,10 +165,12 b' def listlfiles(repo, rev=None, matcher=N'
164 for f in repo[rev].walk(matcher)
165 for f in repo[rev].walk(matcher)
165 if rev is not None or repo.dirstate[f] != '?']
166 if rev is not None or repo.dirstate[f] != '?']
166
167
167 def instore(repo, hash):
168 def instore(repo, hash, forcelocal=False):
168 return os.path.exists(storepath(repo, hash))
169 return os.path.exists(storepath(repo, hash, forcelocal))
169
170
170 def storepath(repo, hash):
171 def storepath(repo, hash, forcelocal=False):
172 if not forcelocal and repo.shared():
173 return repo.vfs.reljoin(repo.sharedpath, longname, hash)
171 return repo.join(longname, hash)
174 return repo.join(longname, hash)
172
175
173 def findstorepath(repo, hash):
176 def findstorepath(repo, hash):
@@ -175,7 +178,17 b' def findstorepath(repo, hash):'
175 hash. If the file is not found, its path in the primary store is returned.
178 hash. If the file is not found, its path in the primary store is returned.
176 The return value is a tuple of (path, exists(path)).
179 The return value is a tuple of (path, exists(path)).
177 '''
180 '''
178 return (storepath(repo, hash), instore(repo, hash))
181 # For shared repos, the primary store is in the share source. But for
182 # backward compatibility, force a lookup in the local store if it wasn't
183 # found in the share source.
184 path = storepath(repo, hash, False)
185
186 if instore(repo, hash):
187 return (path, True)
188 elif repo.shared() and instore(repo, hash, True):
189 return storepath(repo, hash, True)
190
191 return (path, False)
179
192
180 def copyfromcache(repo, hash, filename):
193 def copyfromcache(repo, hash, filename):
181 '''Copy the specified largefile from the repo or system cache to
194 '''Copy the specified largefile from the repo or system cache to
@@ -153,3 +153,29 b' for a forget.)'
153 ENOENT: * (glob)
153 ENOENT: * (glob)
154 not removing z: file is already untracked
154 not removing z: file is already untracked
155 [1]
155 [1]
156
157 Largefiles are accessible from the share's store
158 $ cd ..
159 $ hg share -q src share_dst --config extensions.share=
160 $ hg -R share_dst update -r0
161 getting changed largefiles
162 1 largefiles updated, 0 removed
163 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
164
165 $ echo modified > share_dst/large
166 $ hg -R share_dst ci -m modified
167 created new head
168
169 Only dirstate is in the local store for the share, and the largefile is in the
170 share source's local store. Avoid the extra largefiles added in the unix
171 conditional above.
172 $ hash=`hg -R share_dst cat share_dst/.hglf/large`
173 $ echo $hash
174 e2fb5f2139d086ded2cb600d5a91a196e76bf020
175
176 $ find share_dst/.hg/largefiles/* | sort
177 share_dst/.hg/largefiles/dirstate
178
179 $ find src/.hg/largefiles/* | egrep "(dirstate|$hash)" | sort
180 src/.hg/largefiles/dirstate
181 src/.hg/largefiles/e2fb5f2139d086ded2cb600d5a91a196e76bf020
General Comments 0
You need to be logged in to leave comments. Login now