diff mercurial/hgweb/webcommands.py @ 21121:8c9e84b44221

hgweb: make "comparison" get parent from not filelog but changelog Before this patch, "comparison" shows unexpected result, when the specified file is not modified in the specified revision, even though "diff" shows empty result. When REV doesn't change specified FILE, "diff" shows: "hg diff -c REV FILE" but "comparison" shows: "hg diff -c `hg parents -r REV FILE` FILE" In other words, the former gets parent from changelog, but the latter gets one from filelog. This may confuse users browsing (and switching "diff" and "comparison" of) files in the specified revision. This patch makes "comparison" get parent from not filelog but changelog, to show "hg diff -c REV FILE" in both "diff" and "comparison" pages.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Thu, 17 Apr 2014 09:36:08 +0900
parents 46f93b7660b6
children 92fab48dfec1
line wrap: on
line diff
--- a/mercurial/hgweb/webcommands.py	Thu Apr 17 09:36:08 2014 +0900
+++ b/mercurial/hgweb/webcommands.py	Thu Apr 17 09:36:08 2014 +0900
@@ -717,13 +717,13 @@
         rightrev = fctx.filerev()
         rightnode = fctx.filenode()
         rightlines = filelines(fctx)
-        parents = fctx.parents()
-        if not parents:
+        parent = ctx.p1()
+        if path not in parent:
             leftrev = -1
             leftnode = nullid
             leftlines = ()
         else:
-            pfctx = parents[0]
+            pfctx = parent[path]
             leftrev = pfctx.filerev()
             leftnode = pfctx.filenode()
             leftlines = filelines(pfctx)