# HG changeset patch # User FUJIWARA Katsunori # Date 2017-03-24 13:29:22 # Node ID 8228bc8fed8c709a43baa6c3af418d37c8ccd55c # Parent 1f6c932862e5f9e6e5e03fe808e7028197a159c7 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)