# HG changeset patch # User Matt Mackall # Date 1336993003 -7200 # Node ID 7bf48bc7de23ac9479e41e6333db421e84b4e1ab # Parent 1eede2ea20419066a7cc23d7d4692a7b4e90225d hgweb: fix filediff base calculation Previously, we were finding the most recent version of a file in a changeset and comparing it against its first file parent. This was wrong on three counts: - it would show a diff in revisions where there was no change to a file - it would show a diff when only the exec bit changed - it would potentially compare against a much older changeset, which could be very expensive if git-style rename detection was enabled This compares the file in the current context with that context's parent, which may result in an empty diff when looking at a file not touched by the current changeset. diff -r 1eede2ea2041 -r 7bf48bc7de23 mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py Sun May 13 17:34:55 2012 +0200 +++ b/mercurial/hgweb/webcommands.py Mon May 14 12:56:43 2012 +0200 @@ -558,6 +558,7 @@ if fctx is not None: n = fctx.node() path = fctx.path() + ctx = fctx.changectx() else: n = ctx.node() # path already defined in except clause @@ -567,7 +568,7 @@ if 'style' in req.form: style = req.form['style'][0] - diffs = webutil.diffs(web.repo, tmpl, fctx or ctx, [path], parity, style) + diffs = webutil.diffs(web.repo, tmpl, ctx, [path], parity, style) rename = fctx and webutil.renamelink(fctx) or [] ctx = fctx and fctx or ctx return tmpl("filediff", diff -r 1eede2ea2041 -r 7bf48bc7de23 tests/test-hgweb-commands.t --- a/tests/test-hgweb-commands.t Sun May 13 17:34:55 2012 +0200 +++ b/tests/test-hgweb-commands.t Mon May 14 12:56:43 2012 +0200 @@ -663,15 +663,24 @@ + $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/filediff/0/foo/?style=raw' + 200 Script output follows + + + diff -r 000000000000 -r 2ef0ac749a14 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 @@ + +foo + + + + + $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/filediff/1/foo/?style=raw' 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 @@ - +foo diff -r 1eede2ea2041 -r 7bf48bc7de23 tests/test-hgweb-diffs.t --- a/tests/test-hgweb-diffs.t Sun May 13 17:34:55 2012 +0200 +++ b/tests/test-hgweb-diffs.t Mon May 14 12:56:43 2012 +0200 @@ -13,6 +13,7 @@ change permissions for git diffs $ chmod +x a + $ hg rm b $ hg ci -Amb set up hgweb @@ -90,7 +91,7 @@ children - 78e4ebad7cdf + 559edbd9ed20 files @@ -177,7 +178,7 @@ diff removed file - $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/diff/tip/a' + $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/diff/tip/b' 200 Script output follows @@ -188,7 +189,7 @@ - test: a diff + test: b diff @@ -199,23 +200,23 @@ mercurial