From patchwork Tue Aug 27 18:09:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2, of, 4, V4] hgweb: pass arguments which a function depends on explicitly in search From: Alexander Plavin X-Patchwork-Id: 2277 Message-Id: To: mercurial-devel@selenic.com Date: Tue, 27 Aug 2013 22:09:06 +0400 # HG changeset patch # User Alexander Plavin # Date 1377175330 -14400 # Thu Aug 22 16:42:10 2013 +0400 # Node ID e1404f928161fabcf95ad6c32405cc1cff5e2bb0 # Parent b8d60488e6d505840157b3bae197504dd0f7a079 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. diff -r b8d60488e6d5 -r e1404f928161 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 @@ 'keyword': keywordsearch, } - def getsearchmode(): - return 'keyword' + def getsearchmode(query): + return 'keyword', 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']