Mercurial > public > mercurial-scm > hg
comparison mercurial/templatefuncs.py @ 43051:da3329fe01e3
templatefuncs: account for user's diffopts in diff() (BC)
author | Denis Laxalde <denis@laxalde.org> |
---|---|
date | Sat, 05 Oct 2019 12:03:19 +0200 |
parents | 6704696141b8 |
children | 2372284d9457 |
comparison
equal
deleted
inserted
replaced
43050:a614f26d4897 | 43051:da3329fe01e3 |
---|---|
14 bin, | 14 bin, |
15 wdirid, | 15 wdirid, |
16 ) | 16 ) |
17 from . import ( | 17 from . import ( |
18 color, | 18 color, |
19 diffutil, | |
19 encoding, | 20 encoding, |
20 error, | 21 error, |
21 minirst, | 22 minirst, |
22 obsutil, | 23 obsutil, |
23 pycompat, | 24 pycompat, |
84 | 85 |
85 data.update((k, evalfuncarg(context, mapping, v)) | 86 data.update((k, evalfuncarg(context, mapping, v)) |
86 for k, v in args['kwargs'].iteritems()) | 87 for k, v in args['kwargs'].iteritems()) |
87 return templateutil.hybriddict(data) | 88 return templateutil.hybriddict(data) |
88 | 89 |
89 @templatefunc('diff([includepattern [, excludepattern]])', requires={'ctx'}) | 90 @templatefunc('diff([includepattern [, excludepattern]])', |
91 requires={'ctx', 'ui'}) | |
90 def diff(context, mapping, args): | 92 def diff(context, mapping, args): |
91 """Show a diff, optionally | 93 """Show a diff, optionally |
92 specifying files to include or exclude.""" | 94 specifying files to include or exclude.""" |
93 if len(args) > 2: | 95 if len(args) > 2: |
94 # i18n: "diff" is a keyword | 96 # i18n: "diff" is a keyword |
100 if s: | 102 if s: |
101 return [s] | 103 return [s] |
102 return [] | 104 return [] |
103 | 105 |
104 ctx = context.resource(mapping, 'ctx') | 106 ctx = context.resource(mapping, 'ctx') |
105 chunks = ctx.diff(match=ctx.match([], getpatterns(0), getpatterns(1))) | 107 ui = context.resource(mapping, 'ui') |
108 diffopts = diffutil.diffallopts(ui) | |
109 chunks = ctx.diff(match=ctx.match([], getpatterns(0), getpatterns(1)), | |
110 opts=diffopts) | |
106 | 111 |
107 return ''.join(chunks) | 112 return ''.join(chunks) |
108 | 113 |
109 @templatefunc('extdata(source)', argspec='source', requires={'ctx', 'cache'}) | 114 @templatefunc('extdata(source)', argspec='source', requires={'ctx', 'cache'}) |
110 def extdata(context, mapping, args): | 115 def extdata(context, mapping, args): |