Patchwork [1,of,3,V2] hgweb: add dynamic search function selection, depending on the query

login
register
mail settings
Submitter Alexander Plavin
Date Aug. 16, 2013, 8 p.m.
Message ID <7de4329371abefa30c97.1376683244@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/2180/
State Superseded
Headers show

Comments

Alexander Plavin - Aug. 16, 2013, 8 p.m.
# HG changeset patch
# User Alexander Plavin <alexander@plav.in>
# 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.

Patch

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)