changeset 38583:4bc96c755c17

templatekw: obtain ui directly from the template context
author Yuya Nishihara <yuya@tcha.org>
date Fri, 06 Jul 2018 21:29:05 +0900
parents 7f4bf8110150
children c6398fc2fc9c
files mercurial/templatekw.py
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/templatekw.py	Fri Jul 06 21:28:02 2018 +0900
+++ b/mercurial/templatekw.py	Fri Jul 06 21:29:05 2018 +0900
@@ -258,13 +258,14 @@
     else:
         return s.strip()
 
-@templatekeyword('diffstat', requires={'ctx'})
+@templatekeyword('diffstat', requires={'ui', 'ctx'})
 def showdiffstat(context, mapping):
     """String. Statistics of changes with the following format:
     "modified files: +added/-removed lines"
     """
+    ui = context.resource(mapping, 'ui')
     ctx = context.resource(mapping, 'ctx')
-    diffopts = diffutil.diffopts(ctx._repo.ui, {'noprefix': False})
+    diffopts = diffutil.diffopts(ui, {'noprefix': False})
     diff = ctx.diff(opts=diffopts)
     stats = patch.diffstatdata(util.iterlines(diff))
     maxname, maxtotal, adds, removes, binary = patch.diffstatsum(stats)