# HG changeset patch # User Alexander Plavin # Date 2013-08-22 12:45:23 # Node ID cf9e5e45c1d3ad3f665182cb7576a7a515842f38 # Parent bb67f630b335270bcbd1f5a26c8d46b9edcd8775 hgweb: add dynamic search function selection, depending on the query This allows adding other specific search functions, in addition to current keyword search. diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -138,10 +138,17 @@ def _search(web, req, tmpl): yield ctx + searchfuncs = { + 'keyword': keywordsearch, + } + + def getsearchmode(): + return 'keyword' + 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 @@ def _search(web, req, tmpl): morevars['revcount'] = revcount * 2 morevars['rev'] = query + mode = getsearchmode() + searchfunc = searchfuncs[mode] + tip = web.repo['tip'] parity = paritygen(web.stripecount)