Show More
@@ -263,12 +263,16 b' def changeset(web, req, tmpl):' | |||||
263 | node=ctx.hex(), file=f, |
|
263 | node=ctx.hex(), file=f, | |
264 | parity=parity.next())) |
|
264 | parity=parity.next())) | |
265 |
|
265 | |||
266 | parity = paritygen(web.stripecount) |
|
|||
267 | style = web.config('web', 'style', 'paper') |
|
266 | style = web.config('web', 'style', 'paper') | |
268 | if 'style' in req.form: |
|
267 | if 'style' in req.form: | |
269 | style = req.form['style'][0] |
|
268 | style = req.form['style'][0] | |
270 |
|
269 | |||
|
270 | parity = paritygen(web.stripecount) | |||
271 | diffs = webutil.diffs(web.repo, tmpl, ctx, None, parity, style) |
|
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 | return tmpl('changeset', |
|
276 | return tmpl('changeset', | |
273 | diff=diffs, |
|
277 | diff=diffs, | |
274 | rev=ctx.rev(), |
|
278 | rev=ctx.rev(), | |
@@ -282,6 +286,7 b' def changeset(web, req, tmpl):' | |||||
282 | desc=ctx.description(), |
|
286 | desc=ctx.description(), | |
283 | date=ctx.date(), |
|
287 | date=ctx.date(), | |
284 | files=files, |
|
288 | files=files, | |
|
289 | diffstat=diffstat, | |||
285 | archives=web.archivelist(ctx.hex()), |
|
290 | archives=web.archivelist(ctx.hex()), | |
286 | tags=webutil.nodetagsdict(web.repo, ctx.node()), |
|
291 | tags=webutil.nodetagsdict(web.repo, ctx.node()), | |
287 | bookmarks=webutil.nodebookmarksdict(web.repo, ctx.node()), |
|
292 | bookmarks=webutil.nodebookmarksdict(web.repo, ctx.node()), |
@@ -7,7 +7,7 b'' | |||||
7 | # GNU General Public License version 2 or any later version. |
|
7 | # GNU General Public License version 2 or any later version. | |
8 |
|
8 | |||
9 | import os, copy |
|
9 | import os, copy | |
10 | from mercurial import match, patch, scmutil, error, ui |
|
10 | from mercurial import match, patch, scmutil, error, ui, util | |
11 | from mercurial.node import hex, nullid |
|
11 | from mercurial.node import hex, nullid | |
12 |
|
12 | |||
13 | def up(p): |
|
13 | def up(p): | |
@@ -211,6 +211,26 b' def diffs(repo, tmpl, ctx, files, parity' | |||||
211 | yield tmpl('diffblock', parity=parity.next(), |
|
211 | yield tmpl('diffblock', parity=parity.next(), | |
212 | lines=prettyprintlines(''.join(block))) |
|
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 | class sessionvars(object): |
|
234 | class sessionvars(object): | |
215 | def __init__(self, vars, start='?'): |
|
235 | def __init__(self, vars, start='?'): | |
216 | self.start = start |
|
236 | self.start = start |
General Comments 0
You need to be logged in to leave comments.
Login now