Changeset 4a16e7e40cbd…
Parent 0a2b4117dbb2…
by Andrew Pritchard <andrewp@fogcreek.com>
Changes to one file · Browse files at 4a16e7e40cbd Showing diff from parent 0a2b4117dbb2 Diff from another changeset...
@@ -384,64 +384,50 @@ wlock = repo.wlock()
try:
lfdirstate = lfutil.openlfdirstate(ui, repo)
-
- lfiles = lfutil.listlfiles(repo)
-
+ lfiles = set(lfutil.listlfiles(repo)) | set(lfdirstate)
if filelist is not None:
lfiles = [f for f in lfiles if f in filelist]
if lfiles:
cachelfiles(ui, repo, '.')
- for lfile in lfiles:
- if not os.path.exists(repo.wjoin(lfutil.standin(lfile))):
- lfdirstate.remove(lfile)
- continue
- if os.path.exists(repo.wjoin(lfutil.standin(lfile + '.orig'))):
- shutil.copyfile(repo.wjoin(lfile), repo.wjoin(lfile + '.orig'))
- expectedhash = lfutil.readstandin(repo, lfile)
- mode = os.stat(repo.wjoin(lfutil.standin(lfile))).st_mode
- if not os.path.exists(repo.wjoin(lfile)) or expectedhash != \
- lfutil.hashrepofile(repo, lfile):
- lfutil.copyfromcache(repo, expectedhash, lfile)
- if os.path.exists(repo.wjoin(lfile)) and mode != \
- os.stat(repo.wjoin(lfile)).st_mode:
- os.chmod(repo.wjoin(lfile), mode)
- if lfutil.standin(lfile) not in repo['.']:
- lfdirstate.add(lfile)
- elif expectedhash == lfutil.readstandin(repo, lfile, '.'):
- lfdirstate.normal(lfile)
-
- removed = 0
- for lfile in lfdirstate:
- if filelist is None or lfile in filelist:
- if not os.path.exists(repo.wjoin(lfutil.standin(lfile))):
- if os.path.exists(repo.wjoin(lfile)):
- os.unlink(repo.wjoin(lfile))
- removed += 1
- if lfutil.standin(lfile) in repo['.']:
- lfdirstate.remove(lfile)
- else:
- lfdirstate.forget(lfile)
- else:
- state = repo.dirstate[lfutil.standin(lfile)]
- if state == 'n':
- lfdirstate.normal(lfile)
- elif state == 'r':
- lfdirstate.remove(lfile)
- elif state == 'a':
- lfdirstate.add(lfile)
- elif state == '?':
- try:
- # Mercurial >= 1.9
- lfdirstate.drop(lfile)
- except AttributeError:
- # Mercurial <= 1.8
- lfdirstate.forget(lfile)
+ map(lambda f: _revertlfile(repo, lfdirstate, f), lfiles)
lfdirstate.write()
finally:
wlock.release()
+def _revertlfile(repo, lfdirstate, lfile):
+ abslfile = repo.wjoin(lfile)
+ absstandin = repo.wjoin(lfutil.standin(lfile))
+ if os.path.exists(absstandin):
+ if os.path.exists(absstandin+'.orig'):
+ shutil.copyfile(abslfile, abslfile+'.orig')
+ expecthash = lfutil.readstandin(repo, lfile)
+ if expecthash != '' and \
+ (not os.path.exists(abslfile) or \
+ expecthash != lfutil.hashfile(abslfile)):
+ lfutil.copyfromcache(repo, expecthash, lfile)
+ mode = os.stat(absstandin).st_mode
+ if mode != os.stat(abslfile).st_mode:
+ os.chmod(abslfile, mode)
+ else:
+ if os.path.exists(abslfile):
+ os.unlink(abslfile)
+ state = repo.dirstate[lfutil.standin(lfile)]
+ if state == 'n':
+ lfdirstate.normal(lfile)
+ elif state == 'r':
+ lfdirstate.remove(lfile)
+ elif state == 'a':
+ lfdirstate.add(lfile)
+ elif state == '?':
+ try:
+ # Mercurial >= 1.9
+ lfdirstate.drop(lfile)
+ except AttributeError:
+ # Mercurial <= 1.8
+ lfdirstate.forget(lfile)
+
def cachelfiles(ui, repo, node):
'''cachelfiles ensures that all largefiles needed by the specified revision
are present in the repository's largefile cache.
|
Loading...