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

login
register
mail settings
Submitter Yuya Nishihara
Date July 6, 2018, 1:03 p.m.
Message ID <51201504373d536eafaa.1530882227@mimosa>
Download mbox | patch
Permalink /patch/32664/
State New
Headers show

Comments

Yuya Nishihara - July 6, 2018, 1:03 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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

Patch

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()
 
-@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)