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

login
register
mail settings
Submitter Alexander Plavin
Date July 14, 2013, 9:45 p.m.
Message ID <8c4a2c55d87bff120c49.1373838327@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/1892/
State Superseded
Headers show

Comments

Alexander Plavin - July 14, 2013, 9:45 p.m.
# HG changeset patch
# User Alexander Plavin <me@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

Patch

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
+
     return tmpl('search', query=query, node=tip.hex(),
                 entries=changelist, archives=web.archivelist("tip"),
                 morevars=morevars, lessvars=lessvars)