##// END OF EJS Templates
largefiles: replace invocation of os.path module by vfs in lfcommands.py
liscju -
r28559:30863ca0 default
parent child Browse files
Show More
@@ -104,14 +104,14 def lfconvert(ui, src, dest, *pats, **op
104 lfiles, normalfiles, matcher, size, lfiletohash)
104 lfiles, normalfiles, matcher, size, lfiletohash)
105 ui.progress(_('converting revisions'), None)
105 ui.progress(_('converting revisions'), None)
106
106
107 if os.path.exists(rdst.wjoin(lfutil.shortname)):
107 if rdst.wvfs.exists(lfutil.shortname):
108 shutil.rmtree(rdst.wjoin(lfutil.shortname))
108 rdst.wvfs.rmtree(lfutil.shortname)
109
109
110 for f in lfiletohash.keys():
110 for f in lfiletohash.keys():
111 if os.path.isfile(rdst.wjoin(f)):
111 if rdst.wvfs.isfile(f):
112 os.unlink(rdst.wjoin(f))
112 rdst.wvfs.unlink(f)
113 try:
113 try:
114 os.removedirs(os.path.dirname(rdst.wjoin(f)))
114 rdst.wvfs.removedirs(rdst.wvfs.dirname(f))
115 except OSError:
115 except OSError:
116 pass
116 pass
117
117
@@ -436,20 +436,26 def updatelfiles(ui, repo, filelist=None
436
436
437 update = {}
437 update = {}
438 updated, removed = 0, 0
438 updated, removed = 0, 0
439 wvfs = repo.wvfs
439 for lfile in lfiles:
440 for lfile in lfiles:
440 abslfile = repo.wjoin(lfile)
441 rellfile = lfile
441 abslfileorig = scmutil.origpath(ui, repo, abslfile)
442 rellfileorig = os.path.relpath(
442 absstandin = repo.wjoin(lfutil.standin(lfile))
443 scmutil.origpath(ui, repo, wvfs.join(rellfile)),
443 absstandinorig = scmutil.origpath(ui, repo, absstandin)
444 start=repo.root)
444 if os.path.exists(absstandin):
445 relstandin = lfutil.standin(lfile)
445 if (os.path.exists(absstandinorig) and
446 relstandinorig = os.path.relpath(
446 os.path.exists(abslfile)):
447 scmutil.origpath(ui, repo, wvfs.join(relstandin)),
447 shutil.copyfile(abslfile, abslfileorig)
448 start=repo.root)
448 util.unlinkpath(absstandinorig)
449 if wvfs.exists(relstandin):
450 if (wvfs.exists(relstandinorig) and
451 wvfs.exists(rellfile)):
452 shutil.copyfile(wvfs.join(rellfile),
453 wvfs.join(rellfileorig))
454 wvfs.unlinkpath(relstandinorig)
449 expecthash = lfutil.readstandin(repo, lfile)
455 expecthash = lfutil.readstandin(repo, lfile)
450 if expecthash != '':
456 if expecthash != '':
451 if lfile not in repo[None]: # not switched to normal file
457 if lfile not in repo[None]: # not switched to normal file
452 util.unlinkpath(abslfile, ignoremissing=True)
458 wvfs.unlinkpath(rellfile, ignoremissing=True)
453 # use normallookup() to allocate an entry in largefiles
459 # use normallookup() to allocate an entry in largefiles
454 # dirstate to prevent lfilesrepo.status() from reporting
460 # dirstate to prevent lfilesrepo.status() from reporting
455 # missing files as removed.
461 # missing files as removed.
@@ -460,9 +466,9 def updatelfiles(ui, repo, filelist=None
460 # lfile is added to the repository again. This happens when a
466 # lfile is added to the repository again. This happens when a
461 # largefile is converted back to a normal file: the standin
467 # largefile is converted back to a normal file: the standin
462 # disappears, but a new (normal) file appears as the lfile.
468 # disappears, but a new (normal) file appears as the lfile.
463 if (os.path.exists(abslfile) and
469 if (wvfs.exists(rellfile) and
464 repo.dirstate.normalize(lfile) not in repo[None]):
470 repo.dirstate.normalize(lfile) not in repo[None]):
465 util.unlinkpath(abslfile)
471 wvfs.unlinkpath(rellfile)
466 removed += 1
472 removed += 1
467
473
468 # largefile processing might be slow and be interrupted - be prepared
474 # largefile processing might be slow and be interrupted - be prepared
@@ -487,12 +493,12 def updatelfiles(ui, repo, filelist=None
487
493
488 # copy the state of largefile standin from the repository's
494 # copy the state of largefile standin from the repository's
489 # dirstate to its state in the lfdirstate.
495 # dirstate to its state in the lfdirstate.
490 abslfile = repo.wjoin(lfile)
496 rellfile = lfile
491 absstandin = repo.wjoin(lfutil.standin(lfile))
497 relstandin = lfutil.standin(lfile)
492 if os.path.exists(absstandin):
498 if wvfs.exists(relstandin):
493 mode = os.stat(absstandin).st_mode
499 mode = wvfs.stat(relstandin).st_mode
494 if mode != os.stat(abslfile).st_mode:
500 if mode != wvfs.stat(rellfile).st_mode:
495 os.chmod(abslfile, mode)
501 wvfs.chmod(rellfile, mode)
496 update1 = 1
502 update1 = 1
497
503
498 updated += update1
504 updated += update1
General Comments 0
You need to be logged in to leave comments. Login now