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

Augie Fackler raf at durin42.com
Mon Aug 26 09:43:55 CDT 2013


On Thu, Aug 22, 2013 at 07:09:27PM +0400, Alexander Plavin wrote:
> # 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,

This magic string gets repeated often, over several changesets. Could
I persuade you to give it a descriptive symbolic name so it's more
obvious what it is to future readers?

> +    }
> +
> +    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)
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list