[PATCH 1 of 4] templatekw: extract function that computes and caches file status

Yuya Nishihara yuya at tcha.org
Thu Sep 13 14:10:28 UTC 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1532867952 -32400
#      Sun Jul 29 21:39:12 2018 +0900
# Node ID f1e582f01fcc7382196eb51e03a7864f66f2b87e
# Parent  69e8ae1380b8b506adc5efb470c555121cb3a964
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'})


More information about the Mercurial-devel mailing list