[PATCH 7 of 7] largefiles: avoid redundant standin() invocations
FUJIWARA Katsunori
foozy at lares.dti.ne.jp
Fri Mar 24 09:38:41 EDT 2017
# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1490362162 -32400
# Fri Mar 24 22:29:22 2017 +0900
# Node ID 6d7aec35c2bd7cf62793bd6135861c9a64a66da1
# Parent b0176fef06b79d8e4364bf2befa2522635c4d3ff
largefiles: avoid redundant standin() invocations
There are some code paths, which apply standin() on same value
multilpe times instead of using already standin()-ed value.
"fstandin" is common name for "path to standin file" in lfutil.py, to
avoid shadowing "standin()".
diff --git a/hgext/largefiles/lfcommands.py b/hgext/largefiles/lfcommands.py
--- a/hgext/largefiles/lfcommands.py
+++ b/hgext/largefiles/lfcommands.py
@@ -220,7 +220,8 @@ def _lfconvert_addchangeset(rsrc, rdst,
normalfiles.add(f)
if f in lfiles:
- dstfiles.append(lfutil.standin(f))
+ fstandin = lfutil.standin(f)
+ dstfiles.append(fstandin)
# largefile in manifest if it has not been removed/renamed
if f in ctx.manifest():
fctx = ctx.filectx(f)
@@ -236,7 +237,7 @@ def _lfconvert_addchangeset(rsrc, rdst,
if f not in lfiletohash or lfiletohash[f] != hash:
rdst.wwrite(f, ctx[f].data(), ctx[f].flags())
executable = 'x' in ctx[f].flags()
- lfutil.writestandin(rdst, lfutil.standin(f), hash,
+ lfutil.writestandin(rdst, fstandin, hash,
executable)
lfiletohash[f] = hash
else:
diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py
--- a/hgext/largefiles/lfutil.py
+++ b/hgext/largefiles/lfutil.py
@@ -557,13 +557,13 @@ def updatestandinsbymatch(repo, match):
# removed/renamed)
for lfile in lfiles:
if lfile in modifiedfiles:
- if repo.wvfs.exists(standin(lfile)):
+ fstandin = standin(lfile)
+ if repo.wvfs.exists(fstandin):
# this handles the case where a rebase is being
# performed and the working copy is not updated
# yet.
if repo.wvfs.exists(lfile):
- updatestandin(repo,
- standin(lfile))
+ updatestandin(repo, fstandin)
return match
diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -739,8 +739,9 @@ def overriderevert(orig, ui, repo, ctx,
for lfile in s.modified:
lfutil.updatestandin(repo, lfutil.standin(lfile))
for lfile in s.deleted:
- if (repo.wvfs.exists(lfutil.standin(lfile))):
- repo.wvfs.unlink(lfutil.standin(lfile))
+ fstandin = lfutil.standin(lfile)
+ if (repo.wvfs.exists(fstandin)):
+ repo.wvfs.unlink(fstandin)
oldstandins = lfutil.getstandinsstate(repo)
@@ -1080,8 +1081,8 @@ def cmdutilforget(orig, ui, repo, match,
forget = [f for f in forget if lfutil.standin(f) in repo[None].manifest()]
for f in forget:
- if lfutil.standin(f) not in repo.dirstate and not \
- repo.wvfs.isdir(lfutil.standin(f)):
+ fstandin = lfutil.standin(f)
+ if fstandin not in repo.dirstate and not repo.wvfs.isdir(fstandin):
ui.warn(_('not removing %s: file is already untracked\n')
% m.rel(f))
bad.append(f)
More information about the Mercurial-devel
mailing list