Patchwork [13,of,15,V3] hgweb: use changelog for iteration

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 16, 2013, 1:32 p.m.
Message ID <6127540415952a1cdf10.1358343139@crater2.logilab.fr>
Download mbox | patch
Permalink /patch/650/
State Accepted
Delegated to: Kevin Bullock
Headers show

Comments

Pierre-Yves David - Jan. 16, 2013, 1:32 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1357862880 -3600
# Node ID 6127540415952a1cdf10a6292e04a01ca9c3e238
# Parent  f048717d6e8a5fb3fae5b2241e373cc72de27533
hgweb: use changelog for iteration

Iterating through changelog is  necessary to enforce filtering.

Patch

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -194,14 +194,17 @@  def changelog(web, req, tmpl, shortlog=F
         except error.RepoError:
             return _search(web, req, tmpl) # XXX redirect to 404 page?
 
     def changelist(latestonly, **map):
         l = [] # build a list in forward order for efficiency
+        revs = []
+        if start < end:
+            revs = web.repo.changelog.revs(start, end - 1)
         if latestonly:
-            revs = (end - 1,)
-        else:
-            revs = xrange(start, end)
+            for r in revs:
+                pass
+            revs = (r,)
         for i in revs:
             ctx = web.repo[i]
             n = ctx.node()
             showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n)
             files = webutil.listfilediffs(tmpl, ctx.files(), n, web.maxfiles)
@@ -743,14 +746,15 @@  def filelog(web, req, tmpl):
 
     def entries(latestonly, **map):
         l = []
 
         repo = web.repo
+        revs = repo.changelog.revs(start, end - 1)
         if latestonly:
-            revs = (end - 1,)
-        else:
-            revs = xrange(start, end)
+            for r in revs:
+                pass
+            revs = (r,)
         for i in revs:
             iterfctx = fctx.filectx(i)
 
             l.append({"parity": parity.next(),
                       "filerev": i,