changeset 19738:93b8544c4482

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)
author Alexander Plavin <alexander@plav.in>
date Fri, 06 Sep 2013 13:30:57 +0400
parents ab5442f45441
children 5bdc179e58c1
files mercurial/hgweb/webcommands.py
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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
@@ -271,7 +271,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(),
@@ -309,11 +309,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)