Mercurial > hg
changeset 9402:5d49fdef6fd0
hgweb: show diff header line in raw diffs
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Wed, 26 Aug 2009 14:58:09 +0200 |
parents | f7968bba2307 |
children | 3738c8cff1bf |
files | mercurial/hgweb/webcommands.py mercurial/hgweb/webutil.py tests/test-hgweb-commands.out tests/test-hgweb-diffs tests/test-hgweb-diffs.out |
diffstat | 5 files changed, 66 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/hgweb/webcommands.py Mon Aug 24 12:47:44 2009 +0200 +++ b/mercurial/hgweb/webcommands.py Wed Aug 26 14:58:09 2009 +0200 @@ -236,7 +236,11 @@ parity=parity.next())) parity = paritygen(web.stripecount) - diffs = webutil.diffs(web.repo, tmpl, ctx, None, parity) + style = web.config('web', 'style', 'paper') + if 'style' in req.form: + style = req.form['style'][0] + + diffs = webutil.diffs(web.repo, tmpl, ctx, None, parity, style) return tmpl('changeset', diff=diffs, rev=ctx.rev(), @@ -474,7 +478,11 @@ # path already defined in except clause parity = paritygen(web.stripecount) - diffs = webutil.diffs(web.repo, tmpl, fctx or ctx, [path], parity) + style = web.config('web', 'style', 'paper') + if 'style' in req.form: + style = req.form['style'][0] + + diffs = webutil.diffs(web.repo, tmpl, fctx or ctx, [path], parity, style) rename = fctx and webutil.renamelink(fctx) or [] ctx = fctx and fctx or ctx return tmpl("filediff",
--- a/mercurial/hgweb/webutil.py Mon Aug 24 12:47:44 2009 +0200 +++ b/mercurial/hgweb/webutil.py Wed Aug 26 14:58:09 2009 +0200 @@ -153,7 +153,7 @@ if len(files) > max: yield tmpl('fileellipses') -def diffs(repo, tmpl, ctx, files, parity): +def diffs(repo, tmpl, ctx, files, parity, style): def countgen(): start = 1 @@ -195,7 +195,7 @@ yield tmpl('diffblock', parity=parity.next(), lines=prettyprintlines(''.join(block))) block = [] - if chunk.startswith('diff'): + if chunk.startswith('diff') and style != 'raw': chunk = ''.join(chunk.splitlines(True)[1:]) block.append(chunk) yield tmpl('diffblock', parity=parity.next(),
--- a/tests/test-hgweb-commands.out Mon Aug 24 12:47:44 2009 +0200 +++ b/tests/test-hgweb-commands.out Wed Aug 26 14:58:09 2009 +0200 @@ -337,6 +337,7 @@ # Parent 2ef0ac749a14e4f57a5a822464a0902c6f7f448f Added tag 1.0 for changeset 2ef0ac749a14 +diff -r 2ef0ac749a14 -r a4f92ed23982 .hgtags --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgtags Thu Jan 01 00:00:00 1970 +0000 @@ -0,0 +1,1 @@ @@ -451,6 +452,7 @@ 200 Script output follows +diff -r 000000000000 -r a4f92ed23982 foo --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foo Thu Jan 01 00:00:00 1970 +0000 @@ -0,0 +1,1 @@
--- a/tests/test-hgweb-diffs Mon Aug 24 12:47:44 2009 +0200 +++ b/tests/test-hgweb-diffs Wed Aug 26 14:58:09 2009 +0200 @@ -18,6 +18,9 @@ echo % revision "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/rev/0' +echo % raw revision +"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/raw-rev/0' + echo % diff removed file "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/diff/tip/a' @@ -29,6 +32,9 @@ echo % revision "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/rev/0' +echo % revision +"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/raw-rev/0' + echo % diff removed file "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/diff/tip/a'
--- a/tests/test-hgweb-diffs.out Mon Aug 24 12:47:44 2009 +0200 +++ b/tests/test-hgweb-diffs.out Wed Aug 26 14:58:09 2009 +0200 @@ -95,6 +95,28 @@ </body> </html> +% raw revision +200 Script output follows + + +# HG changeset patch +# User test +# Date 0 0 +# Node ID 0cd96de13884b090099512d4794ae87ad067ea8e + +a + +diff -r 000000000000 -r 0cd96de13884 a +--- /dev/null Thu Jan 01 00:00:00 1970 +0000 ++++ b/a Thu Jan 01 00:00:00 1970 +0000 +@@ -0,0 +1,1 @@ ++a +diff -r 000000000000 -r 0cd96de13884 b +--- /dev/null Thu Jan 01 00:00:00 1970 +0000 ++++ b/b Thu Jan 01 00:00:00 1970 +0000 +@@ -0,0 +1,1 @@ ++b + % diff removed file 200 Script output follows @@ -279,6 +301,30 @@ </body> </html> +% revision +200 Script output follows + + +# HG changeset patch +# User test +# Date 0 0 +# Node ID 0cd96de13884b090099512d4794ae87ad067ea8e + +a + +diff --git a/a b/a +new file mode 100644 +--- /dev/null ++++ b/a +@@ -0,0 +1,1 @@ ++a +diff --git a/b b/b +new file mode 100644 +--- /dev/null ++++ b/b +@@ -0,0 +1,1 @@ ++b + % diff removed file 200 Script output follows