[PATCH 1 of 4 V3] hgweb: add dynamic search function selection, depending on the query
Alexander Plavin
alexander at plav.in
Thu Aug 22 15:09:27 UTC 2013
# HG changeset patch
# User Alexander Plavin <alexander at plav.in>
# Date 1377175523 -14400
# Thu Aug 22 16:45:23 2013 +0400
# Node ID 779319758a3c5ade2123dc4c42d76824111b801b
# Parent a133dfe29d0325c1cea54aebd97599e02b30a861
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 a133dfe29d03 -r 779319758a3c 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 = {
+ '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,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