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

login
register
mail settings
Submitter Alexander Plavin
Date Sept. 18, 2013, 6:03 p.m.
Message ID <17e983fb2af3e26e989d.1379527434@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/2518/
State Accepted
Commit 93b8544c4482e84a662429942153c5b6adb77147
Headers show

Comments

Alexander Plavin - Sept. 18, 2013, 6:03 p.m.
# HG changeset patch
# User Alexander Plavin <alexander@plav.in>
# Date 1378459857 -14400
#      Fri Sep 06 13:30:57 2013 +0400
# Node ID 17e983fb2af3e26e989d31129d8bbc31e4423210
# Parent  cb1c62872a8aa8f03a0353d6432614a922aa786c
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)
Matt Mackall - Sept. 18, 2013, 6:25 p.m.
On Wed, 2013-09-18 at 22:03 +0400, Alexander Plavin wrote:
> # HG changeset patch
> # User Alexander Plavin <alexander@plav.in>
> # Date 1378459857 -14400
> #      Fri Sep 06 13:30:57 2013 +0400
> # Node ID 17e983fb2af3e26e989d31129d8bbc31e4423210
> # Parent  cb1c62872a8aa8f03a0353d6432614a922aa786c
> hgweb: add nextentry variable for easy pagination in changelog

These are queued, thanks.

Patch

diff -r cb1c62872a8a -r 17e983fb2af3 mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py	Fri Sep 06 13:30:57 2013 +0400
+++ b/mercurial/hgweb/webcommands.py	Fri Sep 06 13:30:57 2013 +0400
@@ -287,7 +287,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(),
@@ -325,11 +325,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)