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().
This commit is contained in:
Anton Shestakov 2015-11-28 16:02:22 +08:00
parent 56e13fa832
commit 9f284e62ca
2 changed files with 10 additions and 5 deletions

View File

@ -854,6 +854,7 @@ def comparison(web, req, tmpl):
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 @@ def comparison(web, req, tmpl):
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 @@ def comparison(web, req, tmpl):
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,

View File

@ -927,7 +927,7 @@ comparison removed file
</tr>
<tr>
<th>parents</th>
<td><a href="/file/0cd96de13884/a">0cd96de13884</a> </td>
<td><a href="/file/d73db4d812ff/a">d73db4d812ff</a> </td>
</tr>
<tr>
<th>children</th>