Patchwork [5,of,7] hgweb: wrap {changenav} and {nav} with mappinglist

login
register
mail settings
Submitter Yuya Nishihara
Date April 14, 2018, 12:49 p.m.
Message ID <affefa7df3fe2dd06be7.1523710155@mimosa>
Download mbox | patch
Permalink /patch/31025/
State Accepted
Headers show

Comments

Yuya Nishihara - April 14, 2018, 12:49 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1522593608 -32400
#      Sun Apr 01 23:40:08 2018 +0900
# Node ID affefa7df3fe2dd06be7cab086c16626010bc8b4
# Parent  ec55e9ef2255378a190bdda6f060dca23659cc9d
hgweb: wrap {changenav} and {nav} with mappinglist

Patch

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -1084,7 +1084,7 @@  def filelog(web):
         linerange = webutil.formatlinerange(*lrange)
         # deactivate numeric nav links when linerange is specified as this
         # would required a dedicated "revnav" class
-        nav = []
+        nav = templateutil.mappinglist([])
         if descend:
             it = dagop.blockdescendants(fctx, *lrange)
         else:
diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -125,13 +125,16 @@  class revnav(object):
         :limit: how far shall we link
 
         The return is:
-            - a single element tuple
+            - a single element mappinglist
             - containing a dictionary with a `before` and `after` key
             - values are dictionaries with `label` and `node` keys
         """
         if not self:
             # empty repo
-            return ({'before': (), 'after': ()},)
+            return templateutil.mappinglist([
+                {'before': templateutil.mappinglist([]),
+                 'after': templateutil.mappinglist([])},
+            ])
 
         targets = []
         for f in _navseq(1, pagelen):
@@ -156,7 +159,11 @@  class revnav(object):
 
         navafter.append({'label': 'tip', 'node': 'tip'})
 
-        return ({'before': navbefore, 'after': navafter},)
+        # TODO: maybe this can be a scalar object supporting tomap()
+        return templateutil.mappinglist([
+            {'before': templateutil.mappinglist(navbefore),
+             'after': templateutil.mappinglist(navafter)},
+        ])
 
 class filerevnav(revnav):