changeset 19631:cf9e5e45c1d3

hgweb: add dynamic search function selection, depending on the query This allows adding other specific search functions, in addition to current keyword search.
author Alexander Plavin <alexander@plav.in>
date Thu, 22 Aug 2013 16:45:23 +0400
parents bb67f630b335
children 299511aabf85
files mercurial/hgweb/webcommands.py
diffstat 1 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/webcommands.py	Mon Aug 26 17:11:01 2013 -0700
+++ 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)