mercurial/templatefuncs.py
changeset 43051 da3329fe01e3
parent 41720 6704696141b8
child 43076 2372284d9457
--- a/mercurial/templatefuncs.py	Sat Oct 05 09:57:00 2019 -0400
+++ b/mercurial/templatefuncs.py	Sat Oct 05 12:03:19 2019 +0200
@@ -16,6 +16,7 @@
 )
 from . import (
     color,
+    diffutil,
     encoding,
     error,
     minirst,
@@ -86,7 +87,8 @@
                 for k, v in args['kwargs'].iteritems())
     return templateutil.hybriddict(data)
 
-@templatefunc('diff([includepattern [, excludepattern]])', requires={'ctx'})
+@templatefunc('diff([includepattern [, excludepattern]])',
+              requires={'ctx', 'ui'})
 def diff(context, mapping, args):
     """Show a diff, optionally
     specifying files to include or exclude."""
@@ -102,7 +104,10 @@
         return []
 
     ctx = context.resource(mapping, 'ctx')
-    chunks = ctx.diff(match=ctx.match([], getpatterns(0), getpatterns(1)))
+    ui = context.resource(mapping, 'ui')
+    diffopts = diffutil.diffallopts(ui)
+    chunks = ctx.diff(match=ctx.match([], getpatterns(0), getpatterns(1)),
+                      opts=diffopts)
 
     return ''.join(chunks)