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