[PATCH 2 of 7] templatekw: obtain ui directly from the template context

Yuya Nishihara yuya at tcha.org
Fri Jul 6 09:03:47 EDT 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1530880145 -32400
#      Fri Jul 06 21:29:05 2018 +0900
# Node ID 51201504373d536eafaab28693a3ca588318eb7c
# Parent  36567c3231fe2a7c26a01f7981e6795514bc5aaa
templatekw: obtain ui directly from the template context

diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -258,13 +258,14 @@ def showdescription(context, mapping):
     else:
         return s.strip()
 
- at templatekeyword('diffstat', requires={'ctx'})
+ at 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)


More information about the Mercurial-devel mailing list