comparison mercurial/hgweb/webcommands.py @ 27159:7e10b860c174

webcommands: stop using ersatz if-else ternary operator for rename variable 6ddc86eedc3b didn't remove it, let's do it now. Placing the added lines into the already existing "if fctx is not None" block also makes webcommands.comparison() look a bit more like webcommands.filediff(), which eases possible future refactoring. And fctx is not None only when path in ctx, so logically it's equivalent.
author Anton Shestakov <av6@dwimlabs.net>
date Sat, 28 Nov 2015 16:46:31 +0800
parents 522ffc189671
children c533435cbc37
comparison
equal deleted inserted replaced
27158:522ffc189671 27159:7e10b860c174
836 """ 836 """
837 ctx = webutil.changectx(web.repo, req) 837 ctx = webutil.changectx(web.repo, req)
838 if 'file' not in req.form: 838 if 'file' not in req.form:
839 raise ErrorResponse(HTTP_NOT_FOUND, 'file not given') 839 raise ErrorResponse(HTTP_NOT_FOUND, 'file not given')
840 path = webutil.cleanpath(web.repo, req.form['file'][0]) 840 path = webutil.cleanpath(web.repo, req.form['file'][0])
841 rename = path in ctx and webutil.renamelink(ctx[path]) or []
842 841
843 parsecontext = lambda v: v == 'full' and -1 or int(v) 842 parsecontext = lambda v: v == 'full' and -1 or int(v)
844 if 'context' in req.form: 843 if 'context' in req.form:
845 context = parsecontext(req.form['context'][0]) 844 context = parsecontext(req.form['context'][0])
846 else: 845 else:
873 pfctx = ctx.parents()[0][path] 872 pfctx = ctx.parents()[0][path]
874 leftlines = filelines(pfctx) 873 leftlines = filelines(pfctx)
875 874
876 comparison = webutil.compare(tmpl, context, leftlines, rightlines) 875 comparison = webutil.compare(tmpl, context, leftlines, rightlines)
877 if fctx is not None: 876 if fctx is not None:
877 rename = webutil.renamelink(fctx)
878 ctx = fctx 878 ctx = fctx
879 else: 879 else:
880 rename = []
880 ctx = ctx 881 ctx = ctx
881 return tmpl('filecomparison', 882 return tmpl('filecomparison',
882 file=path, 883 file=path,
883 node=hex(ctx.node()), 884 node=hex(ctx.node()),
884 rev=ctx.rev(), 885 rev=ctx.rev(),