# HG changeset patch # User Yuya Nishihara # Date 2018-07-29 12:39:12 # Node ID 164827563426d1de6cb5d81f7d97f64d6cd1d8ce # Parent 409c42d6a5705ebaf33850ea4e91667b06ee903e templatekw: extract function that computes and caches file status diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py --- a/mercurial/templatekw.py +++ b/mercurial/templatekw.py @@ -291,12 +291,16 @@ def showextras(context, mapping): return _hybrid(f, extras, makemap, lambda k: '%s=%s' % (k, stringutil.escapestr(extras[k]))) -def _showfilesbystat(context, mapping, name, index): +def _getfilestatus(context, mapping): ctx = context.resource(mapping, 'ctx') revcache = context.resource(mapping, 'revcache') if 'files' not in revcache: revcache['files'] = ctx.p1().status(ctx)[:3] - files = revcache['files'][index] + return revcache['files'] + +def _showfilesbystat(context, mapping, name, index): + stat = _getfilestatus(context, mapping) + files = stat[index] return templateutil.compatfileslist(context, mapping, name, files) @templatekeyword('file_adds', requires={'ctx', 'revcache'})