Patchwork [STABLE] hgweb: prevent traceback during search when filtered (issue3783)

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 29, 2013, 3:45 p.m.
Message ID <30d4573a4160a6ff5ec3.1359474358@crater1.logilab.fr>
Download mbox | patch
Permalink /patch/754/
State Accepted
Commit a58d8936647aa270854cd919fe8e8b2da1c1c669
Delegated to: Kevin Bullock
Headers show

Comments

Pierre-Yves David - Jan. 29, 2013, 3:45 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@logilab.fr>
# Date 1359474291 -3600
# Branch stable
# Node ID 30d4573a4160a6ff5ec3ad4fdf65f36f96c97901
# Parent  1bd91b32ef1a0cc5d60fa30ff6dc49d031914927
hgweb: prevent traceback during search when filtered (issue3783)

The search needs to iterate over the repo using changelog.revs like the rest of
the Mercurial code.

Patch

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -127,13 +127,14 @@  def _search(web, req, tmpl):
         count = 0
         lower = encoding.lower
         qw = lower(query).split()
 
         def revgen():
+            cl = web.repo.changelog
             for i in xrange(len(web.repo) - 1, 0, -100):
                 l = []
-                for j in xrange(max(0, i - 100), i + 1):
+                for j in cl.revs(max(0, i - 100), i + 1):
                     ctx = web.repo[j]
                     l.append(ctx)
                 l.reverse()
                 for e in l:
                     yield e
diff --git a/tests/test-hgweb-commands.t b/tests/test-hgweb-commands.t
--- a/tests/test-hgweb-commands.t
+++ b/tests/test-hgweb-commands.t
@@ -1390,6 +1390,16 @@  listbookmarks hides secret bookmarks
 
   $ PATH_INFO=/; export PATH_INFO
   $ QUERY_STRING='cmd=listkeys&namespace=bookmarks'
   $ python hgweb.cgi
 
+search works with filtering
+
+  $ PATH_INFO=/log; export PATH_INFO
+  $ QUERY_STRING='rev=babar'
+  $ python hgweb.cgi > search
+  $ grep Status search
+  Status: 200 Script output follows\r (esc)
+
   $ cd ..
+
+