Show More
@@ -120,20 +120,21 b' def openlfdirstate(ui, repo, create=True' | |||
|
120 | 120 | Return a dirstate object that tracks largefiles: i.e. its root is |
|
121 | 121 | the repo root, but it is saved in .hg/largefiles/dirstate. |
|
122 | 122 | ''' |
|
123 | lfstoredir = repo.join(longname) | |
|
124 | opener = scmutil.opener(lfstoredir) | |
|
123 | vfs = repo.vfs | |
|
124 | lfstoredir = longname | |
|
125 | opener = scmutil.opener(vfs.join(lfstoredir)) | |
|
125 | 126 | lfdirstate = largefilesdirstate(opener, ui, repo.root, |
|
126 | 127 | repo.dirstate._validate) |
|
127 | 128 | |
|
128 | 129 | # If the largefiles dirstate does not exist, populate and create |
|
129 | 130 | # it. This ensures that we create it on the first meaningful |
|
130 | 131 | # largefiles operation in a new clone. |
|
131 |
if create and not |
|
|
132 | if create and not vfs.exists(vfs.join(lfstoredir, 'dirstate')): | |
|
132 | 133 | matcher = getstandinmatcher(repo) |
|
133 | 134 | standins = repo.dirstate.walk(matcher, [], False, False) |
|
134 | 135 | |
|
135 | 136 | if len(standins) > 0: |
|
136 |
|
|
|
137 | vfs.makedirs(lfstoredir) | |
|
137 | 138 | |
|
138 | 139 | for standin in standins: |
|
139 | 140 | lfile = splitstandin(standin) |
@@ -200,30 +201,30 b' def copyfromcache(repo, hash, filename):' | |||
|
200 | 201 | file was not found in either cache (which should not happened: |
|
201 | 202 | this is meant to be called only after ensuring that the needed |
|
202 | 203 | largefile exists in the cache).''' |
|
204 | wvfs = repo.wvfs | |
|
203 | 205 | path = findfile(repo, hash) |
|
204 | 206 | if path is None: |
|
205 | 207 | return False |
|
206 |
|
|
|
208 | wvfs.makedirs(wvfs.dirname(wvfs.join(filename))) | |
|
207 | 209 | # The write may fail before the file is fully written, but we |
|
208 | 210 | # don't use atomic writes in the working copy. |
|
209 | dest = repo.wjoin(filename) | |
|
210 | 211 | with open(path, 'rb') as srcfd: |
|
211 |
with |
|
|
212 | with wvfs(filename, 'wb') as destfd: | |
|
212 | 213 | gothash = copyandhash(srcfd, destfd) |
|
213 | 214 | if gothash != hash: |
|
214 | 215 | repo.ui.warn(_('%s: data corruption in %s with hash %s\n') |
|
215 | 216 | % (filename, path, gothash)) |
|
216 |
|
|
|
217 | wvfs.unlink(filename) | |
|
217 | 218 | return False |
|
218 | 219 | return True |
|
219 | 220 | |
|
220 | 221 | def copytostore(repo, rev, file, uploaded=False): |
|
222 | wvfs = repo.wvfs | |
|
221 | 223 | hash = readstandin(repo, file, rev) |
|
222 | 224 | if instore(repo, hash): |
|
223 | 225 | return |
|
224 | absfile = repo.wjoin(file) | |
|
225 | if os.path.exists(absfile): | |
|
226 | copytostoreabsolute(repo, absfile, hash) | |
|
226 | if wvfs.exists(file): | |
|
227 | copytostoreabsolute(repo, wvfs.join(file), hash) | |
|
227 | 228 | else: |
|
228 | 229 | repo.ui.warn(_("%s: largefile %s not available from local store\n") % |
|
229 | 230 | (file, hash)) |
@@ -257,21 +258,22 b' def linktousercache(repo, hash):' | |||
|
257 | 258 | |
|
258 | 259 | def getstandinmatcher(repo, rmatcher=None): |
|
259 | 260 | '''Return a match object that applies rmatcher to the standin directory''' |
|
260 | standindir = repo.wjoin(shortname) | |
|
261 | wvfs = repo.wvfs | |
|
262 | standindir = shortname | |
|
261 | 263 | |
|
262 | 264 | # no warnings about missing files or directories |
|
263 | 265 | badfn = lambda f, msg: None |
|
264 | 266 | |
|
265 | 267 | if rmatcher and not rmatcher.always(): |
|
266 |
pats = [ |
|
|
268 | pats = [wvfs.join(standindir, pat) for pat in rmatcher.files()] | |
|
267 | 269 | if not pats: |
|
268 | pats = [standindir] | |
|
270 | pats = [wvfs.join(standindir)] | |
|
269 | 271 | match = scmutil.match(repo[None], pats, badfn=badfn) |
|
270 | 272 | # if pats is empty, it would incorrectly always match, so clear _always |
|
271 | 273 | match._always = False |
|
272 | 274 | else: |
|
273 | 275 | # no patterns: relative to repo root |
|
274 | match = scmutil.match(repo[None], [standindir], badfn=badfn) | |
|
276 | match = scmutil.match(repo[None], [wvfs.join(standindir)], badfn=badfn) | |
|
275 | 277 | return match |
|
276 | 278 | |
|
277 | 279 | def composestandinmatcher(repo, rmatcher): |
@@ -315,7 +317,7 b' def splitstandin(filename):' | |||
|
315 | 317 | |
|
316 | 318 | def updatestandin(repo, standin): |
|
317 | 319 | file = repo.wjoin(splitstandin(standin)) |
|
318 | if os.path.exists(file): | |
|
320 | if repo.wvfs.exists(splitstandin(standin)): | |
|
319 | 321 | hash = hashfile(file) |
|
320 | 322 | executable = getexecutable(file) |
|
321 | 323 | writestandin(repo, standin, hash, executable) |
@@ -419,7 +421,7 b' def synclfdirstate(repo, lfdirstate, lfi' | |||
|
419 | 421 | state, mtime = '?', -1 |
|
420 | 422 | if state == 'n': |
|
421 | 423 | if (normallookup or mtime < 0 or |
|
422 |
not o |
|
|
424 | not repo.wvfs.exists(lfile)): | |
|
423 | 425 | # state 'n' doesn't ensure 'clean' in this case |
|
424 | 426 | lfdirstate.normallookup(lfile) |
|
425 | 427 | else: |
@@ -525,12 +527,11 b' def updatestandinsbymatch(repo, match):' | |||
|
525 | 527 | # removed/renamed) |
|
526 | 528 | for lfile in lfiles: |
|
527 | 529 | if lfile in modifiedfiles: |
|
528 |
if o |
|
|
529 | repo.wjoin(standin(lfile))): | |
|
530 | if repo.wvfs.exists(standin(lfile)): | |
|
530 | 531 | # this handles the case where a rebase is being |
|
531 | 532 | # performed and the working copy is not updated |
|
532 | 533 | # yet. |
|
533 |
if o |
|
|
534 | if repo.wvfs.exists(lfile): | |
|
534 | 535 | updatestandin(repo, |
|
535 | 536 | standin(lfile)) |
|
536 | 537 |
General Comments 0
You need to be logged in to leave comments.
Login now