Changeset b30307e35409…
Parent 4a16e7e40cbd…
by Andrew Pritchard <andrewp@fogcreek.com>
Changes to one file · Browse files at b30307e35409 Showing diff from parent 4a16e7e40cbd Diff from another changeset...
|
@@ -397,6 +397,7 @@ wlock.release()
def _revertlfile(repo, lfdirstate, lfile):
+ ret = 0
abslfile = repo.wjoin(lfile)
absstandin = repo.wjoin(lfutil.standin(lfile))
if os.path.exists(absstandin):
@@ -406,13 +407,17 @@ if expecthash != '' and \
(not os.path.exists(abslfile) or \
expecthash != lfutil.hashfile(abslfile)):
- lfutil.copyfromcache(repo, expecthash, lfile)
+ if not lfutil.copyfromcache(repo, expecthash, lfile):
+ return False # don't try to set the mode or update the dirstate
+ ret = 1
mode = os.stat(absstandin).st_mode
if mode != os.stat(abslfile).st_mode:
os.chmod(abslfile, mode)
+ ret = 1
else:
if os.path.exists(abslfile):
os.unlink(abslfile)
+ ret = -1
state = repo.dirstate[lfutil.standin(lfile)]
if state == 'n':
lfdirstate.normal(lfile)
@@ -427,6 +432,7 @@ except AttributeError:
# Mercurial <= 1.8
lfdirstate.forget(lfile)
+ return ret
def cachelfiles(ui, repo, node):
'''cachelfiles ensures that all largefiles needed by the specified revision
@@ -459,58 +465,21 @@ wlock = repo.wlock()
try:
lfdirstate = lfutil.openlfdirstate(ui, repo)
+ lfiles = set(lfutil.listlfiles(repo)) | set(lfdirstate)
- lfiles = lfutil.listlfiles(repo)
- at = 0
- updated = 0
- removed = 0
printed = False
if lfiles:
ui.status(_('getting changed largefiles\n'))
printed = True
+ cachelfiles(ui, repo, '.')
- success, missing = cachelfiles(ui, repo, None)
-
- for lfile in lfiles:
- at += 1
- if os.path.exists(repo.wjoin(lfile)) and not \
- os.path.exists(repo.wjoin(lfutil.standin(lfile))):
- os.unlink(repo.wjoin(lfile))
- removed += 1
- lfdirstate.forget(lfutil.unixpath(lfile))
- continue
- expectedhash = repo[None][lfutil.standin(lfile)].data().strip()
- mode = os.stat(repo.wjoin(lfutil.standin(lfile))).st_mode
- if not os.path.exists(repo.wjoin(lfile)) or expectedhash != \
- lfutil.hashfile(repo.wjoin(lfile)):
- path = lfutil.findfile(repo, expectedhash)
- if path:
- util.makedirs(os.path.dirname(repo.wjoin(lfile)))
- shutil.copy(path, repo.wjoin(lfile))
- os.chmod(repo.wjoin(lfile), mode)
- updated += 1
- lfdirstate.normal(lfutil.unixpath(lfile))
- elif os.path.exists(repo.wjoin(lfile)) and mode != \
- os.stat(repo.wjoin(lfile)).st_mode:
- os.chmod(repo.wjoin(lfile), mode)
- updated += 1
- lfdirstate.normal(lfutil.unixpath(lfile))
-
- for lfile in lfdirstate:
- if lfile not in lfiles:
- if os.path.exists(repo.wjoin(lfile)):
- if not printed:
- ui.status(_('getting changed largefiles\n'))
- printed = True
- os.unlink(repo.wjoin(lfile))
- removed += 1
- path = lfutil.unixpath(lfile)
- try:
- # Mercurial >= 1.9
- lfdirstate.drop(path)
- except AttributeError:
- # Mercurial <= 1.8
- lfdirstate.forget(path)
+ updated, removed = 0, 0
+ for i in map(lambda f: _revertlfile(repo, lfdirstate, f), lfiles):
+ updated += i > 0 and i or 0
+ removed -= i < 0 and i or 0
+ if (removed or updated) and not printed:
+ ui.status(_('getting changed largefiles\n'))
+ printed = True
lfdirstate.write()
if printed:
|
Loading...