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

login
register
mail settings
Submitter Alexander Plavin
Date Aug. 27, 2013, 6:09 p.m.
Message ID <b8d60488e6d505840157.1377626945@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/2275/
State Accepted
Headers show

Comments

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

Patch

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)