comparison mercurial/templatekw.py @ 38564:64f15e22f4f8

template: directly instantiate diff options for diffstat
author Boris Feld <boris.feld@octobus.net>
date Sat, 23 Jun 2018 14:30:31 +0200
parents f2f9bacf0587
children 4bc96c755c17
comparison
equal deleted inserted replaced
38563:b9724978633e 38564:64f15e22f4f8
25 scmutil, 25 scmutil,
26 templateutil, 26 templateutil,
27 util, 27 util,
28 ) 28 )
29 from .utils import ( 29 from .utils import (
30 diffutil,
30 stringutil, 31 stringutil,
31 ) 32 )
32 33
33 _hybrid = templateutil.hybrid 34 _hybrid = templateutil.hybrid
34 hybriddict = templateutil.hybriddict 35 hybriddict = templateutil.hybriddict
261 def showdiffstat(context, mapping): 262 def showdiffstat(context, mapping):
262 """String. Statistics of changes with the following format: 263 """String. Statistics of changes with the following format:
263 "modified files: +added/-removed lines" 264 "modified files: +added/-removed lines"
264 """ 265 """
265 ctx = context.resource(mapping, 'ctx') 266 ctx = context.resource(mapping, 'ctx')
266 diff = ctx.diff(opts={'noprefix': False}) 267 diffopts = diffutil.diffopts(ctx._repo.ui, {'noprefix': False})
268 diff = ctx.diff(opts=diffopts)
267 stats = patch.diffstatdata(util.iterlines(diff)) 269 stats = patch.diffstatdata(util.iterlines(diff))
268 maxname, maxtotal, adds, removes, binary = patch.diffstatsum(stats) 270 maxname, maxtotal, adds, removes, binary = patch.diffstatsum(stats)
269 return '%d: +%d/-%d' % (len(stats), adds, removes) 271 return '%d: +%d/-%d' % (len(stats), adds, removes)
270 272
271 @templatekeyword('envvars', requires={'ui'}) 273 @templatekeyword('envvars', requires={'ui'})