paul@50 | 1 | # HG changeset patch |
paul@50 | 2 | # User Paul Boddie <paul@boddie.org.uk> |
paul@50 | 3 | # Date 1322607647 -3600 |
paul@50 | 4 | # Node ID 387585e3105efc9df33e947527950ced65320201 |
paul@50 | 5 | # Parent ad686c818e1c7d5ed0335327321003ba8ea04664 |
paul@50 | 6 | hgweb: Introduce a blockno variable in the changeset's files list and in the diffs webcommand |
paul@50 | 7 | |
paul@50 | 8 | diff -r ad686c818e1c -r 387585e3105e mercurial/hgweb/webcommands.py |
paul@50 | 9 | --- a/mercurial/hgweb/webcommands.py Fri Nov 25 02:11:12 2011 +0100 |
paul@50 | 10 | +++ b/mercurial/hgweb/webcommands.py Wed Nov 30 00:00:47 2011 +0100 |
paul@39 | 11 | @@ -261,10 +261,10 @@ |
paul@39 | 12 | |
paul@39 | 13 | files = [] |
paul@39 | 14 | parity = paritygen(web.stripecount) |
paul@39 | 15 | - for f in ctx.files(): |
paul@39 | 16 | + for blockno, f in enumerate(ctx.files()): |
paul@39 | 17 | template = f in ctx and 'filenodelink' or 'filenolink' |
paul@39 | 18 | files.append(tmpl(template, |
paul@39 | 19 | - node=ctx.hex(), file=f, |
paul@39 | 20 | + node=ctx.hex(), file=f, blockno=blockno+1, |
paul@39 | 21 | parity=parity.next())) |
paul@39 | 22 | |
paul@39 | 23 | style = web.config('web', 'style', 'paper') |
paul@50 | 24 | diff -r ad686c818e1c -r 387585e3105e mercurial/hgweb/webutil.py |
paul@50 | 25 | --- a/mercurial/hgweb/webutil.py Fri Nov 25 02:11:12 2011 +0100 |
paul@50 | 26 | +++ b/mercurial/hgweb/webutil.py Wed Nov 30 00:00:47 2011 +0100 |
paul@39 | 27 | @@ -173,8 +173,7 @@ |
paul@39 | 28 | start += 1 |
paul@39 | 29 | |
paul@39 | 30 | blockcount = countgen() |
paul@39 | 31 | - def prettyprintlines(diff): |
paul@39 | 32 | - blockno = blockcount.next() |
paul@39 | 33 | + def prettyprintlines(diff, blockno): |
paul@39 | 34 | for lineno, l in enumerate(diff.splitlines(True)): |
paul@39 | 35 | lineno = "%d.%d" % (blockno, lineno + 1) |
paul@39 | 36 | if l.startswith('+'): |
paul@39 | 37 | @@ -203,14 +202,16 @@ |
paul@39 | 38 | block = [] |
paul@39 | 39 | for chunk in patch.diff(repo, node1, node2, m, opts=diffopts): |
paul@39 | 40 | if chunk.startswith('diff') and block: |
paul@39 | 41 | - yield tmpl('diffblock', parity=parity.next(), |
paul@39 | 42 | - lines=prettyprintlines(''.join(block))) |
paul@39 | 43 | + blockno = blockcount.next() |
paul@39 | 44 | + yield tmpl('diffblock', parity=parity.next(), blockno=blockno, |
paul@39 | 45 | + lines=prettyprintlines(''.join(block), blockno)) |
paul@39 | 46 | block = [] |
paul@39 | 47 | if chunk.startswith('diff') and style != 'raw': |
paul@39 | 48 | chunk = ''.join(chunk.splitlines(True)[1:]) |
paul@39 | 49 | block.append(chunk) |
paul@39 | 50 | - yield tmpl('diffblock', parity=parity.next(), |
paul@39 | 51 | - lines=prettyprintlines(''.join(block))) |
paul@39 | 52 | + blockno = blockcount.next() |
paul@39 | 53 | + yield tmpl('diffblock', parity=parity.next(), blockno=blockno, |
paul@39 | 54 | + lines=prettyprintlines(''.join(block), blockno)) |
paul@39 | 55 | |
paul@39 | 56 | def diffstatgen(ctx): |
paul@39 | 57 | '''Generator function that provides the diffstat data.''' |