diff mercurial/hgweb/webutil.py @ 21122:50981ce36236

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
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Thu, 17 Apr 2014 09:36:08 +0900
parents 52e5aca15f0c
children 513d47905114
line wrap: on
line diff
--- 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):