Patchwork [2,of,4] hgweb: cleaner if conditions in changelog() function

login
register
mail settings
Submitter Alexander Plavin
Date Aug. 2, 2013, 9:55 p.m.
Message ID <4d2594e04563e2a8b0f6.1375480541@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/1997/
State Accepted
Commit 983bb4069004a4df9bbfd49327adacb7994b3434
Headers show

Comments

Alexander Plavin - Aug. 2, 2013, 9:55 p.m.
# HG changeset patch
# User Alexander Plavin <alexander@plav.in>
# Date 1374185299 -14400
#      Fri Jul 19 02:08:19 2013 +0400
# Node ID 4d2594e04563e2a8b0f63f46a6ad867bec686691
# Parent  ff99b04ed3eef4b077f4e6b93e5adf919b0d691d
hgweb: cleaner if conditions in changelog() function

This removes unneeded extra nesting level and extra variable, which makes
the code easier to understand.

Patch

diff -r ff99b04ed3ee -r 4d2594e04563 mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py	Mon Jul 15 01:10:22 2013 +0400
+++ b/mercurial/hgweb/webcommands.py	Fri Jul 19 02:08:19 2013 +0400
@@ -193,16 +193,14 @@ 
     query = ''
     if 'node' in req.form:
         ctx = webutil.changectx(web.repo, req)
-    else:
-        if 'rev' in req.form:
-            query = req.form['rev'][0]
-            hi = query
-        else:
-            hi = 'tip'
+    elif 'rev' in req.form:
+        query = req.form['rev'][0]
         try:
-            ctx = web.repo[hi]
+            ctx = web.repo[query]
         except (error.RepoError, error.LookupError):
             return _search(web, req, tmpl) # XXX redirect to 404 page?
+    else:
+        ctx = web.repo['tip']
 
     def changelist(latestonly, **map):
         revs = []