From patchwork Fri Aug 16 20:00:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1, of, 3, V2] hgweb: add dynamic search function selection, depending on the query From: Alexander Plavin X-Patchwork-Id: 2180 Message-Id: <7de4329371abefa30c97.1376683244@debian-alexander.dolgopa> To: mercurial-devel@selenic.com Date: Sat, 17 Aug 2013 00:00:44 +0400 # HG changeset patch # User Alexander Plavin # Date 1376652944 -14400 # Fri Aug 16 15:35:44 2013 +0400 # Node ID 7de4329371abefa30c9776084d54fd1cb9e0e6c3 # Parent 74dbeaab9631fe063e55e130f699242ab4dfc01e 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 74dbeaab9631 -r 7de4329371ab mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py Wed Jul 24 03:20:26 2013 +0400 +++ b/mercurial/hgweb/webcommands.py Fri Aug 16 15:35:44 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,8 @@ morevars['revcount'] = revcount * 2 morevars['rev'] = query + searchfunc = searchfuncs[getsearchmode()] + tip = web.repo['tip'] parity = paritygen(web.stripecount)