comparison mercurial/hgweb/webcommands.py @ 27158:522ffc189671

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().
author Anton Shestakov <av6@dwimlabs.net>
date Sat, 28 Nov 2015 16:02:22 +0800
parents 37290f2f2c3b
children 7e10b860c174
comparison
equal deleted inserted replaced
27157:5f2e4eb08e41 27158:522ffc189671
852 if not mt: 852 if not mt:
853 mt = 'application/octet-stream' 853 mt = 'application/octet-stream'
854 return [_('(binary file %s, hash: %s)') % (mt, hex(f.filenode()))] 854 return [_('(binary file %s, hash: %s)') % (mt, hex(f.filenode()))]
855 return f.data().splitlines() 855 return f.data().splitlines()
856 856
857 fctx = None
857 parent = ctx.p1() 858 parent = ctx.p1()
858 leftrev = parent.rev() 859 leftrev = parent.rev()
859 leftnode = parent.node() 860 leftnode = parent.node()
860 rightrev = ctx.rev() 861 rightrev = ctx.rev()
861 rightnode = ctx.node() 862 rightnode = ctx.node()
867 else: 868 else:
868 pfctx = parent[path] 869 pfctx = parent[path]
869 leftlines = filelines(pfctx) 870 leftlines = filelines(pfctx)
870 else: 871 else:
871 rightlines = () 872 rightlines = ()
872 fctx = ctx.parents()[0][path] 873 pfctx = ctx.parents()[0][path]
873 leftlines = filelines(fctx) 874 leftlines = filelines(pfctx)
874 875
875 comparison = webutil.compare(tmpl, context, leftlines, rightlines) 876 comparison = webutil.compare(tmpl, context, leftlines, rightlines)
877 if fctx is not None:
878 ctx = fctx
879 else:
880 ctx = ctx
876 return tmpl('filecomparison', 881 return tmpl('filecomparison',
877 file=path, 882 file=path,
878 node=hex(ctx.node()), 883 node=hex(ctx.node()),
879 rev=ctx.rev(), 884 rev=ctx.rev(),
880 symrev=webutil.symrevorshortnode(req, ctx), 885 symrev=webutil.symrevorshortnode(req, ctx),
882 desc=ctx.description(), 887 desc=ctx.description(),
883 extra=ctx.extra(), 888 extra=ctx.extra(),
884 author=ctx.user(), 889 author=ctx.user(),
885 rename=rename, 890 rename=rename,
886 branch=webutil.nodebranchnodefault(ctx), 891 branch=webutil.nodebranchnodefault(ctx),
887 parent=webutil.parents(fctx), 892 parent=webutil.parents(ctx),
888 child=webutil.children(fctx), 893 child=webutil.children(ctx),
889 tags=webutil.nodetagsdict(web.repo, ctx.node()), 894 tags=webutil.nodetagsdict(web.repo, ctx.node()),
890 bookmarks=webutil.nodebookmarksdict(web.repo, ctx.node()), 895 bookmarks=webutil.nodebookmarksdict(web.repo, ctx.node()),
891 leftrev=leftrev, 896 leftrev=leftrev,
892 leftnode=hex(leftnode), 897 leftnode=hex(leftnode),
893 rightrev=rightrev, 898 rightrev=rightrev,