Patchwork [3,of,3,V2] hgweb: add nextentry variable for easy pagination in changelog

login
register
mail settings
Submitter Alexander Plavin
Date Aug. 17, 2013, 10:27 p.m.
Message ID <ae42151fc56ecc420f3f.1376778475@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/2200/
State Superseded
Commit 93b8544c4482e84a662429942153c5b6adb77147
Headers show

Comments

Alexander Plavin - Aug. 17, 2013, 10:27 p.m.
# HG changeset patch
# User Alexander Plavin <alexander@plav.in>
# Date 1376739205 -14400
#      Sat Aug 17 15:33:25 2013 +0400
# Node ID ae42151fc56ecc420f3fac291110a81476609b22
# Parent  75805f44a32239ec77e7f4c1bc7232c85c7b8d7b
hgweb: add nextentry variable for easy pagination in changelog

nextentry always contains the first entry not shown on current page (if there is
such entry)

Patch

diff -r 75805f44a322 -r ae42151fc56e mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py	Fri Aug 09 07:22:36 2013 +0400
+++ b/mercurial/hgweb/webcommands.py	Sat Aug 17 15:33:25 2013 +0400
@@ -283,7 +283,7 @@ 
             files = webutil.listfilediffs(tmpl, ctx.files(), n, web.maxfiles)
 
             curcount += 1
-            if curcount > revcount:
+            if curcount > revcount + 1:
                 break
             yield {"parity": parity.next(),
                    "author": ctx.user(),
@@ -321,11 +321,16 @@ 
 
     entries = list(changelist())
     latestentry = entries[:1]
+    if len(entries) > revcount:
+        nextentry = entries[-1:]
+        entries = entries[:-1]
+    else:
+        nextentry = []
 
     return tmpl(shortlog and 'shortlog' or 'changelog', changenav=changenav,
                 node=ctx.hex(), rev=pos, changesets=count,
                 entries=entries,
-                latestentry=latestentry,
+                latestentry=latestentry, nextentry=nextentry,
                 archives=web.archivelist("tip"), revcount=revcount,
                 morevars=morevars, lessvars=lessvars, query=query)