Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/webutil.py @ 14562:fccd3b966da7
web: provide the file number to the diffstat templates
This allows the diffstat templates to link into the diff output. For example,
the URLs of the first three files within the diff are #l1.1, #l2.1, #l3.1.
author | Steven Brown <StevenGBrown@gmail.com> |
---|---|
date | Thu, 09 Jun 2011 01:15:49 +0800 |
parents | 925d9f2b188b |
children | 9f908ef5a595 |
comparison
equal
deleted
inserted
replaced
14561:925d9f2b188b | 14562:fccd3b966da7 |
---|---|
221 def pct(i): | 221 def pct(i): |
222 if maxtotal == 0: | 222 if maxtotal == 0: |
223 return 0 | 223 return 0 |
224 return (float(i) / maxtotal) * 100 | 224 return (float(i) / maxtotal) * 100 |
225 | 225 |
226 fileno = 0 | |
226 for filename, adds, removes, isbinary in stats: | 227 for filename, adds, removes, isbinary in stats: |
227 template = filename in files and 'diffstatlink' or 'diffstatnolink' | 228 template = filename in files and 'diffstatlink' or 'diffstatnolink' |
228 total = adds + removes | 229 total = adds + removes |
229 yield tmpl(template, node=ctx.hex(), file=filename, | 230 fileno += 1 |
231 yield tmpl(template, node=ctx.hex(), file=filename, fileno=fileno, | |
230 total=total, addpct=pct(adds), removepct=pct(removes), | 232 total=total, addpct=pct(adds), removepct=pct(removes), |
231 parity=parity.next()) | 233 parity=parity.next()) |
232 | 234 |
233 class sessionvars(object): | 235 class sessionvars(object): |
234 def __init__(self, vars, start='?'): | 236 def __init__(self, vars, start='?'): |