##// END OF EJS Templates
hgweb: add block numbers to diff regions and related links...
Paul Boddie -
r16308:2695aaf4 default
parent child Browse files
Show More
@@ -262,10 +262,10 b' def changeset(web, req, tmpl):'
262
262
263 files = []
263 files = []
264 parity = paritygen(web.stripecount)
264 parity = paritygen(web.stripecount)
265 for f in ctx.files():
265 for blockno, f in enumerate(ctx.files()):
266 template = f in ctx and 'filenodelink' or 'filenolink'
266 template = f in ctx and 'filenodelink' or 'filenolink'
267 files.append(tmpl(template,
267 files.append(tmpl(template,
268 node=ctx.hex(), file=f,
268 node=ctx.hex(), file=f, blockno=blockno + 1,
269 parity=parity.next()))
269 parity=parity.next()))
270
270
271 style = web.config('web', 'style', 'paper')
271 style = web.config('web', 'style', 'paper')
@@ -173,8 +173,7 b' def diffs(repo, tmpl, ctx, files, parity'
173 start += 1
173 start += 1
174
174
175 blockcount = countgen()
175 blockcount = countgen()
176 def prettyprintlines(diff):
176 def prettyprintlines(diff, blockno):
177 blockno = blockcount.next()
178 for lineno, l in enumerate(diff.splitlines(True)):
177 for lineno, l in enumerate(diff.splitlines(True)):
179 lineno = "%d.%d" % (blockno, lineno + 1)
178 lineno = "%d.%d" % (blockno, lineno + 1)
180 if l.startswith('+'):
179 if l.startswith('+'):
@@ -203,14 +202,16 b' def diffs(repo, tmpl, ctx, files, parity'
203 block = []
202 block = []
204 for chunk in patch.diff(repo, node1, node2, m, opts=diffopts):
203 for chunk in patch.diff(repo, node1, node2, m, opts=diffopts):
205 if chunk.startswith('diff') and block:
204 if chunk.startswith('diff') and block:
206 yield tmpl('diffblock', parity=parity.next(),
205 blockno = blockcount.next()
207 lines=prettyprintlines(''.join(block)))
206 yield tmpl('diffblock', parity=parity.next(), blockno=blockno,
207 lines=prettyprintlines(''.join(block), blockno))
208 block = []
208 block = []
209 if chunk.startswith('diff') and style != 'raw':
209 if chunk.startswith('diff') and style != 'raw':
210 chunk = ''.join(chunk.splitlines(True)[1:])
210 chunk = ''.join(chunk.splitlines(True)[1:])
211 block.append(chunk)
211 block.append(chunk)
212 yield tmpl('diffblock', parity=parity.next(),
212 blockno = blockcount.next()
213 lines=prettyprintlines(''.join(block)))
213 yield tmpl('diffblock', parity=parity.next(), blockno=blockno,
214 lines=prettyprintlines(''.join(block), blockno))
214
215
215 def diffstatgen(ctx):
216 def diffstatgen(ctx):
216 '''Generator function that provides the diffstat data.'''
217 '''Generator function that provides the diffstat data.'''
@@ -552,6 +552,51 b' test import rev as raw-rev'
552 $ cd test1
552 $ cd test1
553 $ hg import -q --exact http://localhost:$HGPORT/rev/1
553 $ hg import -q --exact http://localhost:$HGPORT/rev/1
554
554
555 raw revision with diff block numbers
556
557 $ "$TESTDIR/killdaemons.py"
558 $ cat <<EOF > .hg/hgrc
559 > [web]
560 > templates = rawdiff
561 > EOF
562 $ mkdir rawdiff
563 $ cat <<EOF > rawdiff/map
564 > mimetype = 'text/plain; charset={encoding}'
565 > changeset = '{diff}'
566 > difflineplus = '{line}'
567 > difflineminus = '{line}'
568 > difflineat = '{line}'
569 > diffline = '{line}'
570 > filenodelink = ''
571 > filenolink = ''
572 > fileline = '{line}'
573 > diffblock = 'Block: {blockno}\n{lines}\n'
574 > EOF
575 $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
576 $ cat hg.pid >> $DAEMON_PIDS
577 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/raw-rev/0'
578 200 Script output follows
579
580 Block: 1
581 diff -r 000000000000 -r 0cd96de13884 a
582 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
583 +++ b/a Thu Jan 01 00:00:00 1970 +0000
584 @@ -0,0 +1,1 @@
585 +a
586
587 Block: 2
588 diff -r 000000000000 -r 0cd96de13884 b
589 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
590 +++ b/b Thu Jan 01 00:00:00 1970 +0000
591 @@ -0,0 +1,1 @@
592 +b
593
594 $ "$TESTDIR/killdaemons.py"
595 $ rm .hg/hgrc rawdiff/map
596 $ rmdir rawdiff
597 $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
598 $ cat hg.pid >> $DAEMON_PIDS
599
555 errors
600 errors
556
601
557 $ cat ../test/errors.log
602 $ cat ../test/errors.log
General Comments 0
You need to be logged in to leave comments. Login now