webcommands: stop using ersatz if-else ternary operator for rename variable
authorAnton Shestakov <av6@dwimlabs.net>
Sat, 28 Nov 2015 16:46:31 +0800
changeset 27159 7e10b860c174
parent 27158 522ffc189671
child 27160 c533435cbc37
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.
mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py	Sat Nov 28 16:02:22 2015 +0800
+++ b/mercurial/hgweb/webcommands.py	Sat Nov 28 16:46:31 2015 +0800
@@ -838,7 +838,6 @@
     if 'file' not in req.form:
         raise ErrorResponse(HTTP_NOT_FOUND, 'file not given')
     path = webutil.cleanpath(web.repo, req.form['file'][0])
-    rename = path in ctx and webutil.renamelink(ctx[path]) or []
 
     parsecontext = lambda v: v == 'full' and -1 or int(v)
     if 'context' in req.form:
@@ -875,8 +874,10 @@
 
     comparison = webutil.compare(tmpl, context, leftlines, rightlines)
     if fctx is not None:
+        rename = webutil.renamelink(fctx)
         ctx = fctx
     else:
+        rename = []
         ctx = ctx
     return tmpl('filecomparison',
                 file=path,