[PATCH 2 of 4 RFC] hgweb: separate search itself and template generation into two functions

Kevin Bullock kbullock+mercurial at ringworld.org
Wed Jul 17 14:24:59 CDT 2013


On 14 Jul 2013, at 4:45 PM, Alexander Plavin wrote:

> # HG changeset patch
> # User Alexander Plavin <me at aplavin.ru>
> # Date 1373836222 -14400
> #      Mon Jul 15 01:10:22 2013 +0400
> # Node ID 8c4a2c55d87bff120c49b6c65c124f47df02a26c
> # Parent  28d3d31e969f8e539455963953962c87a1025066
> hgweb: separate search itself and template generation into two functions
> 
> diff -r 28d3d31e969f -r 8c4a2c55d87b mercurial/hgweb/webcommands.py
> --- a/mercurial/hgweb/webcommands.py	Mon Jul 15 01:05:42 2013 +0400
> +++ b/mercurial/hgweb/webcommands.py	Mon Jul 15 01:10:22 2013 +0400
> @@ -110,8 +110,7 @@
> 
> def _search(web, req, tmpl):
> 
> -    def changelist(**map):
> -        count = 0
> +    def simplesearch():
>         lower = encoding.lower
>         qw = lower(query).split()
> 
> @@ -137,6 +136,12 @@
>             if miss:
>                 continue
> 
> +            yield ctx
> +
> +    def changelist(**map):
> +        count = 0
> +
> +        for ctx in searchf():
>             count += 1
>             n = ctx.node()
>             showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n)
> @@ -179,6 +184,8 @@
>     tip = web.repo['tip']
>     parity = paritygen(web.stripecount)
> 
> +    searchf = simplesearch

Why the extra alias here?

pacem in terris / мир / शान्ति / ‎‫سَلاَم‬ / 平和
Kevin R. Bullock



More information about the Mercurial-devel mailing list