##// END OF EJS Templates
web: provide diffstat to the changeset page...
Steven Brown -
r14490:1d3e2349 default
parent child Browse files
Show More
@@ -263,12 +263,16 b' def changeset(web, req, tmpl):'
263 263 node=ctx.hex(), file=f,
264 264 parity=parity.next()))
265 265
266 parity = paritygen(web.stripecount)
267 266 style = web.config('web', 'style', 'paper')
268 267 if 'style' in req.form:
269 268 style = req.form['style'][0]
270 269
270 parity = paritygen(web.stripecount)
271 271 diffs = webutil.diffs(web.repo, tmpl, ctx, None, parity, style)
272
273 parity = paritygen(web.stripecount)
274 diffstat = lambda: webutil.diffstat(tmpl, ctx, parity)
275
272 276 return tmpl('changeset',
273 277 diff=diffs,
274 278 rev=ctx.rev(),
@@ -282,6 +286,7 b' def changeset(web, req, tmpl):'
282 286 desc=ctx.description(),
283 287 date=ctx.date(),
284 288 files=files,
289 diffstat=diffstat,
285 290 archives=web.archivelist(ctx.hex()),
286 291 tags=webutil.nodetagsdict(web.repo, ctx.node()),
287 292 bookmarks=webutil.nodebookmarksdict(web.repo, ctx.node()),
@@ -7,7 +7,7 b''
7 7 # GNU General Public License version 2 or any later version.
8 8
9 9 import os, copy
10 from mercurial import match, patch, scmutil, error, ui
10 from mercurial import match, patch, scmutil, error, ui, util
11 11 from mercurial.node import hex, nullid
12 12
13 13 def up(p):
@@ -211,6 +211,26 b' def diffs(repo, tmpl, ctx, files, parity'
211 211 yield tmpl('diffblock', parity=parity.next(),
212 212 lines=prettyprintlines(''.join(block)))
213 213
214 def diffstat(tmpl, ctx, parity):
215 '''Return a diffstat template for each file in the cset.'''
216
217 stats = patch.diffstatdata(util.iterlines(ctx.diff()))
218 maxname, maxtotal, addtotal, removetotal, binary = patch.diffstatsum(stats)
219
220 statsdict = {}
221 if maxtotal > 0:
222 for filename, adds, removes, isbinary in stats:
223 total = adds + removes
224 addpct = (float(adds) / maxtotal) * 100
225 removepct = (float(removes) / maxtotal) * 100
226 statsdict[filename] = (total, addpct, removepct)
227
228 for f in ctx.files():
229 template = f in ctx and 'diffstatlink' or 'diffstatnolink'
230 total, addpct, removepct = statsdict.get(f, ('', 0, 0))
231 yield tmpl(template, node=ctx.hex(), file=f, total=total,
232 addpct=addpct, removepct=removepct, parity=parity.next())
233
214 234 class sessionvars(object):
215 235 def __init__(self, vars, start='?'):
216 236 self.start = start
General Comments 0
You need to be logged in to leave comments. Login now