From patchwork Tue Aug 27 18:09:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1, of, 4, V4] hgweb: add dynamic search function selection, depending on the query From: Alexander Plavin X-Patchwork-Id: 2275 Message-Id: To: mercurial-devel@selenic.com Date: Tue, 27 Aug 2013 22:09:05 +0400 # HG changeset patch # User Alexander Plavin # Date 1377175523 -14400 # Thu Aug 22 16:45:23 2013 +0400 # Node ID b8d60488e6d505840157b3bae197504dd0f7a079 # Parent 53a0f3a3a2a3bd3e839fc5d6d4eb045a632b91e7 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 53a0f3a3a2a3 -r b8d60488e6d5 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 = { + '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 @@ morevars['revcount'] = revcount * 2 morevars['rev'] = query + mode = getsearchmode() + searchfunc = searchfuncs[mode] + tip = web.repo['tip'] parity = paritygen(web.stripecount)