# HG changeset patch # User Anton Shestakov # Date 1448697742 -28800 # Node ID 522ffc1896712dfb79ef8248e5b4f4d05a8d9cc4 # Parent 5f2e4eb08e41f794d6db8dafdeed1e86ce39608b webcommands: get correct parents when comparing a removed file (issue4962) When comparing a file that was removed at the current revision, parents used to show grandparents instead, due to how fctx was "shifted" from the current revision to its p1. Let's not do that. The fix is pretty much copied from webcommands.filediff(). diff -r 5f2e4eb08e41 -r 522ffc189671 mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py Mon Nov 30 16:38:29 2015 -0800 +++ b/mercurial/hgweb/webcommands.py Sat Nov 28 16:02:22 2015 +0800 @@ -854,6 +854,7 @@ return [_('(binary file %s, hash: %s)') % (mt, hex(f.filenode()))] return f.data().splitlines() + fctx = None parent = ctx.p1() leftrev = parent.rev() leftnode = parent.node() @@ -869,10 +870,14 @@ leftlines = filelines(pfctx) else: rightlines = () - fctx = ctx.parents()[0][path] - leftlines = filelines(fctx) + pfctx = ctx.parents()[0][path] + leftlines = filelines(pfctx) comparison = webutil.compare(tmpl, context, leftlines, rightlines) + if fctx is not None: + ctx = fctx + else: + ctx = ctx return tmpl('filecomparison', file=path, node=hex(ctx.node()), @@ -884,8 +889,8 @@ author=ctx.user(), rename=rename, branch=webutil.nodebranchnodefault(ctx), - parent=webutil.parents(fctx), - child=webutil.children(fctx), + parent=webutil.parents(ctx), + child=webutil.children(ctx), tags=webutil.nodetagsdict(web.repo, ctx.node()), bookmarks=webutil.nodebookmarksdict(web.repo, ctx.node()), leftrev=leftrev, diff -r 5f2e4eb08e41 -r 522ffc189671 tests/test-hgweb-diffs.t --- a/tests/test-hgweb-diffs.t Mon Nov 30 16:38:29 2015 -0800 +++ b/tests/test-hgweb-diffs.t Sat Nov 28 16:02:22 2015 +0800 @@ -927,7 +927,7 @@ parents - 0cd96de13884 + d73db4d812ff children