Patchwork [2,of,3] hgweb: fix incorrect way to count revisions in log (issue3977)

login
register
mail settings
Submitter Alexander Plavin
Date July 20, 2013, 1:32 p.m.
Message ID <b7abfadc267c6d018b38.1374327179@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/1937/
State Superseded
Headers show

Comments

Alexander Plavin - July 20, 2013, 1:32 p.m.
# HG changeset patch
# User Alexander Plavin <me@aplavin.ru>
# Date 1374322072 -14400
#      Sat Jul 20 16:07:52 2013 +0400
# Branch stable
# Node ID b7abfadc267c6d018b38f424c0d568f99c0009e1
# Parent  2f40791f03b930ba39b2305c5bbd6163b324222b
hgweb: fix incorrect way to count revisions in log (issue3977)

Actual amount of revisions is used now instead of their numbers in the repo
befor to deal with skipped numbers correctly.
This iterates starting from the newest revision (which is shown on top)
yielding up to the specified count, instead of the reversed order used before.
Effect of this change on efficiency is negligible, when the same changesets are
returned.

Patch

diff -r 2f40791f03b9 -r b7abfadc267c mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py	Sat Jul 20 16:05:59 2013 +0400
+++ b/mercurial/hgweb/webcommands.py	Sat Jul 20 16:07:52 2013 +0400
@@ -249,10 +249,7 @@ 
         ctx = web.repo['tip']
 
     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)
+        revs = web.repo.changelog.revs(pos, count=-revcount)
         if latestonly:
             for r in revs:
                 pass
@@ -263,24 +260,22 @@ 
             showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n)
             files = webutil.listfilediffs(tmpl, ctx.files(), n, web.maxfiles)
 
-            l.append({"parity": parity.next(),
-                      "author": ctx.user(),
-                      "parent": webutil.parents(ctx, i - 1),
-                      "child": webutil.children(ctx, i + 1),
-                      "changelogtag": showtags,
-                      "desc": ctx.description(),
-                      "extra": ctx.extra(),
-                      "date": ctx.date(),
-                      "files": files,
-                      "rev": i,
-                      "node": hex(n),
-                      "tags": webutil.nodetagsdict(web.repo, n),
-                      "bookmarks": webutil.nodebookmarksdict(web.repo, n),
-                      "inbranch": webutil.nodeinbranch(web.repo, ctx),
-                      "branches": webutil.nodebranchdict(web.repo, ctx)
-                     })
-        for e in reversed(l):
-            yield e
+            yield {"parity": parity.next(),
+                   "author": ctx.user(),
+                   "parent": webutil.parents(ctx, i - 1),
+                   "child": webutil.children(ctx, i + 1),
+                   "changelogtag": showtags,
+                   "desc": ctx.description(),
+                   "extra": ctx.extra(),
+                   "date": ctx.date(),
+                   "files": files,
+                   "rev": i,
+                   "node": hex(n),
+                   "tags": webutil.nodetagsdict(web.repo, n),
+                   "bookmarks": webutil.nodebookmarksdict(web.repo, n),
+                   "inbranch": webutil.nodeinbranch(web.repo, ctx),
+                   "branches": webutil.nodebranchdict(web.repo, ctx)
+            }
 
     revcount = shortlog and web.maxshortchanges or web.maxchanges
     if 'revcount' in req.form:
@@ -295,9 +290,7 @@ 
 
     count = len(web.repo)
     pos = ctx.rev()
-    start = max(0, pos - revcount + 1)
-    end = pos + 1
-    parity = paritygen(web.stripecount, offset=start - end)
+    parity = paritygen(web.stripecount)
 
     changenav = webutil.revnav(web.repo).gen(pos, revcount, count)