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

Alexander Plavin alexander at plav.in
Tue Aug 27 13:09:05 CDT 2013


# HG changeset patch
# User Alexander Plavin <alexander at 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.

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)
 


More information about the Mercurial-devel mailing list