changeset 39613:164827563426

templatekw: extract function that computes and caches file status
author Yuya Nishihara <yuya@tcha.org>
date Sun, 29 Jul 2018 21:39:12 +0900
parents 409c42d6a570
children 42209f55c599
files mercurial/templatekw.py
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/templatekw.py	Thu Sep 13 22:32:51 2018 +0900
+++ b/mercurial/templatekw.py	Sun Jul 29 21:39:12 2018 +0900
@@ -291,12 +291,16 @@
     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'})