From patchwork Tue Jan 29 15:45:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [STABLE] hgweb: prevent traceback during search when filtered (issue3783) From: Pierre-Yves David X-Patchwork-Id: 754 Message-Id: <30d4573a4160a6ff5ec3.1359474358@crater1.logilab.fr> To: mercurial-devel@selenic.com Cc: pierre-yves.david@logilab.fr Date: Tue, 29 Jan 2013 16:45:58 +0100 # HG changeset patch # User Pierre-Yves David # 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. 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 .. + +