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