Patchwork [2,of,4,V3] hgweb: pass arguments which a function depends on explicitly in search

login
register
mail settings
Submitter Alexander Plavin
Date Aug. 22, 2013, 3:09 p.m.
Message ID <16fe12bb559fe7e920fa.1377184168@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/2243/
State Superseded
Commit 299511aabf8578065b3d97be4eb636e15d746738
Headers show

Comments

Alexander Plavin - Aug. 22, 2013, 3:09 p.m.
# HG changeset patch
# User Alexander Plavin <alexander@plav.in>
# Date 1377175330 -14400
#      Thu Aug 22 16:42:10 2013 +0400
# Node ID 16fe12bb559fe7e920fa413470c29780d1810983
# Parent  779319758a3c5ade2123dc4c42d76824111b801b
hgweb: pass arguments which a function depends on explicitly in search

This changes makes clearer which arguments can a function depend on. Now all
the modified functions depend on the 'query' argument only, but future additions
will change it.

Patch

diff -r 779319758a3c -r 16fe12bb559f mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py	Thu Aug 22 16:45:23 2013 +0400
+++ b/mercurial/hgweb/webcommands.py	Thu Aug 22 16:42:10 2013 +0400
@@ -110,7 +110,7 @@ 
 
 def _search(web, req, tmpl):
 
-    def keywordsearch():
+    def keywordsearch(query):
         lower = encoding.lower
         qw = lower(query).split()
 
@@ -142,13 +142,13 @@ 
         'kw': keywordsearch,
     }
 
-    def getsearchmode():
-        return 'kw'
+    def getsearchmode(query):
+        return 'kw', query
 
     def changelist(**map):
         count = 0
 
-        for ctx in searchfunc():
+        for ctx in searchfunc(funcarg):
             count += 1
             n = ctx.node()
             showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n)
@@ -188,7 +188,7 @@ 
     morevars['revcount'] = revcount * 2
     morevars['rev'] = query
 
-    mode = getsearchmode()
+    mode, funcarg = getsearchmode(query)
     searchfunc = searchfuncs[mode]
 
     tip = web.repo['tip']