# HG changeset patch # User FUJIWARA Katsunori # Date 1397694968 -32400 # Node ID 50981ce3623672f4644248d7a16497f0063cae44 # Parent 8c9e84b442218f35eb3125e4c4576a0dcfabbb37 hgweb: show as same parents as "hg parents -r REV FILE" in pages for file Before this patch, "parents" in pages for file doesn't show as same parents as "hg parents -r REV FILE", when the specified file is not modified in the specified revision. For example, it is assumed that revision A, B and D change file "f". changelog (A) ---> (B) ---> (C) ---> (D) filelog "f" (x) ---> (y) ------------> (z) "/file/D/f" invokes "webutil.parents()" with filectx(z) gotten from changectx(D), and it returns changectx(B). This is as same result as "hg parents -r D f". In the other hand, "/file/C/f" invokes "webutil.parents()" with filectx(y') gotten from changectx(C), and it returns changectx(A), because filectx(y') is linked to changectx(B), and works like filectx(y) in some cases. In this case, revision B is hidden from users browsing file "f" in revision C. This patch shows as same parents as "hg parents -r REV FILE" in pages for file, by making "webutil.parents()" return: - "linkrev()"-ed revision only, if: - specified context instance is "filectx" (because "webutil.parents()" is invoked with changectx, too), and - (1) the revision from which filectx is gotten and (2) the one to which filectx is linked are different from each other - revision gotten from "ctx.parents()", otherwise diff -r 8c9e84b44221 -r 50981ce36236 mercurial/hgweb/webutil.py --- a/mercurial/hgweb/webutil.py Thu Apr 17 09:36:08 2014 +0900 +++ b/mercurial/hgweb/webutil.py Thu Apr 17 09:36:08 2014 +0900 @@ -7,7 +7,7 @@ # GNU General Public License version 2 or any later version. import os, copy -from mercurial import match, patch, error, ui, util, pathutil +from mercurial import match, patch, error, ui, util, pathutil, context from mercurial.i18n import _ from mercurial.node import hex, nullid from common import ErrorResponse @@ -138,6 +138,9 @@ yield d def parents(ctx, hide=None): + if (isinstance(ctx, context.basefilectx) and + ctx.changectx().rev() != ctx.linkrev()): + return _siblings([ctx._repo[ctx.linkrev()]], hide) return _siblings(ctx.parents(), hide) def children(ctx, hide=None): diff -r 8c9e84b44221 -r 50981ce36236 tests/test-hgweb-commands.t --- a/tests/test-hgweb-commands.t Thu Apr 17 09:36:08 2014 +0900 +++ b/tests/test-hgweb-commands.t Thu Apr 17 09:36:08 2014 +0900 @@ -928,6 +928,13 @@ -rw-r--r-- 4 foo + $ hg log --template "{file_mods}\n" -r 1 + + $ hg parents --template "{node|short}\n" -r 1 + 2ef0ac749a14 + $ hg parents --template "{node|short}\n" -r 1 foo + 2ef0ac749a14 + $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT 'file/1/foo' 200 Script output follows @@ -998,7 +1005,7 @@ parents - + 2ef0ac749a14 children @@ -1045,6 +1052,109 @@ + $ hg log --template "{file_mods}\n" -r 2 + foo + $ hg parents --template "{node|short}\n" -r 2 + a4f92ed23982 + $ hg parents --template "{node|short}\n" -r 2 foo + 2ef0ac749a14 + + $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT 'file/2/foo' + 200 Script output follows + + + + + + + + + + test: 1d22e65f027e foo + + + +
+ + +
+ +

view foo @ 2:1d22e65f027e

+ + + +
branch
+ + + + + + + + + + + + + + + + + + +
authortest
dateThu, 01 Jan 1970 00:00:00 +0000
parents2ef0ac749a14
children
+ +
+
line wrap: on
+
line source
+
+  another
+
+
+
+
+ + + + + + + + + Overviews $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT 'raw-tags' diff -r 8c9e84b44221 -r 50981ce36236 tests/test-hgweb-diffs.t --- a/tests/test-hgweb-diffs.t Thu Apr 17 09:36:08 2014 +0900 +++ b/tests/test-hgweb-diffs.t Thu Apr 17 09:36:08 2014 +0900 @@ -193,6 +193,14 @@ diff removed file + $ hg log --template "{file_mods}\n{file_dels}\n" -r tip + a + b + $ hg parents --template "{node|short}\n" -r tip + 0cd96de13884 + $ hg parents --template "{node|short}\n" -r tip b + 0cd96de13884 + $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'diff/tip/b' 200 Script output follows @@ -459,7 +467,15 @@ +b -diff removed file +diff modified file + + $ hg log --template "{file_mods}\n{file_dels}\n" -r tip + a + b + $ hg parents --template "{node|short}\n" -r tip + 0cd96de13884 + $ hg parents --template "{node|short}\n" -r tip a + 0cd96de13884 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'diff/tip/a' 200 Script output follows @@ -531,7 +547,7 @@ parents - + 0cd96de13884 children @@ -934,6 +950,10 @@ $ hg tip --template "{node|short}\n" 41d9fc4a6ae1 $ hg diff -c tip e + $ hg parents --template "{node|short}\n" -r tip + 402bea3b0976 + $ hg parents --template "{node|short}\n" -r tip e + 402bea3b0976 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'comparison/tip/e' 200 Script output follows @@ -1005,7 +1025,7 @@ parents - + 402bea3b0976 children