From patchwork Thu Aug 22 15:09:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1, of, 4, V3] hgweb: add dynamic search function selection, depending on the query From: Alexander Plavin X-Patchwork-Id: 2240 Message-Id: <779319758a3c5ade2123.1377184167@debian-alexander.dolgopa> To: mercurial-devel@selenic.com Date: Thu, 22 Aug 2013 19:09:27 +0400 # HG changeset patch # User Alexander Plavin # Date 1377175523 -14400 # Thu Aug 22 16:45:23 2013 +0400 # Node ID 779319758a3c5ade2123dc4c42d76824111b801b # Parent a133dfe29d0325c1cea54aebd97599e02b30a861 hgweb: add dynamic search function selection, depending on the query This allows adding other specific search functions, in addition to current keyword search. diff -r a133dfe29d03 -r 779319758a3c mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py Wed Jul 24 03:20:26 2013 +0400 +++ b/mercurial/hgweb/webcommands.py Thu Aug 22 16:45:23 2013 +0400 @@ -138,10 +138,17 @@ yield ctx + searchfuncs = { + 'kw': keywordsearch, + } + + def getsearchmode(): + return 'kw' + def changelist(**map): count = 0 - for ctx in keywordsearch(): + for ctx in searchfunc(): count += 1 n = ctx.node() showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n) @@ -181,6 +188,9 @@ morevars['revcount'] = revcount * 2 morevars['rev'] = query + mode = getsearchmode() + searchfunc = searchfuncs[mode] + tip = web.repo['tip'] parity = paritygen(web.stripecount)