# HG changeset patch # User Denis Laxalde # Date 2019-10-05 10:03:19 # Node ID da3329fe01e3044f14223eeb8c6dd07842e495ad # Parent a614f26d4897c3f467efaf63172c2ffe5e26a4d5 templatefuncs: account for user's diffopts in diff() (BC) diff --git a/mercurial/templatefuncs.py b/mercurial/templatefuncs.py --- a/mercurial/templatefuncs.py +++ b/mercurial/templatefuncs.py @@ -16,6 +16,7 @@ from .node import ( ) from . import ( color, + diffutil, encoding, error, minirst, @@ -86,7 +87,8 @@ def dict_(context, mapping, args): 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 @@ def diff(context, mapping, args): 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) diff --git a/tests/test-template-functions.t b/tests/test-template-functions.t --- a/tests/test-template-functions.t +++ b/tests/test-template-functions.t @@ -370,6 +370,17 @@ Test diff function: @@ -0,0 +1,1 @@ +second + $ hg --config diff.git=true log -r 8 -T "{diff()}" + diff --git a/second b/fourth + rename from second + rename to fourth + diff --git a/third b/third + new file mode 100644 + --- /dev/null + +++ b/third + @@ -0,0 +1,1 @@ + +third + $ cd .. latesttag() function: