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

Alexander Plavin alexander at plav.in
Wed Sep 18 13:03:54 CDT 2013


# HG changeset patch
# User Alexander Plavin <alexander at 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)

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)
 


More information about the Mercurial-devel mailing list