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

pierre-yves.david at logilab.fr pierre-yves.david at logilab.fr
Wed Jan 16 07:32:19 CST 2013


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1357862880 -3600
# Node ID 6127540415952a1cdf10a6292e04a01ca9c3e238
# Parent  f048717d6e8a5fb3fae5b2241e373cc72de27533
hgweb: use changelog for iteration

Iterating through changelog is  necessary to enforce filtering.

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,


More information about the Mercurial-devel mailing list