Patchwork [6,of,8] hgweb: fix type of {nav} keyword when linerange filter is active

login
register
mail settings
Submitter Yuya Nishihara
Date April 5, 2018, 2:37 p.m.
Message ID <1c22443660286f711ea1.1522939044@mimosa>
Download mbox | patch
Permalink /patch/30381/
State Accepted
Headers show

Comments

Yuya Nishihara - April 5, 2018, 2:37 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1521375537 -32400
#      Sun Mar 18 21:18:57 2018 +0900
# Node ID 1c22443660286f711ea1c6993f6aef77d82a5c63
# Parent  a55c83d928093ea1e1b8d40eee4e799fb3bfe0cd
hgweb: fix type of {nav} keyword when linerange filter is active

Spotted by making '%' operator check the operand type more strictly. Before,
"{nav}" would be evaluated to a lazy "" (empty string) and {"" % x} would
yield one empty string.

Patch

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -1082,7 +1082,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 = None
+        nav = []
         if descend:
             it = dagop.blockdescendants(fctx, *lrange)
         else:
diff --git a/tests/test-hgweb-filelog.t b/tests/test-hgweb-filelog.t
--- a/tests/test-hgweb-filelog.t
+++ b/tests/test-hgweb-filelog.t
@@ -755,7 +755,7 @@  before addition - error
   <div class="navigate">
   <a href="/log/tip/c?linerange=1%3A2&revcount=30">less</a>
   <a href="/log/tip/c?linerange=1%3A2&revcount=120">more</a>
-  |  </div>
+  | </div>
   
   <table class="bigtable">
   <thead>
@@ -791,7 +791,7 @@  before addition - error
   <div class="navigate">
   <a href="/log/tip/c?linerange=1%3A2&revcount=30">less</a>
   <a href="/log/tip/c?linerange=1%3A2&revcount=120">more</a>
-  |  
+  | 
   </div>
   
   </div>
@@ -875,7 +875,7 @@  before addition - error
   <div class="navigate">
   <a href="/log/tip/c?linerange=1%3A2&revcount=1">less</a>
   <a href="/log/tip/c?linerange=1%3A2&revcount=2">more</a>
-  |  </div>
+  | </div>
   
   <table class="bigtable">
   <thead>
@@ -902,7 +902,7 @@  before addition - error
   <div class="navigate">
   <a href="/log/tip/c?linerange=1%3A2&revcount=1">less</a>
   <a href="/log/tip/c?linerange=1%3A2&revcount=2">more</a>
-  |  
+  | 
   </div>
   
   </div>
@@ -1394,7 +1394,7 @@  filelog with 'linerange' and 'patch'
   <div class="navigate">
   <a href="/log/tip/c?linerange=3%3A4&patch=&revcount=30">less</a>
   <a href="/log/tip/c?linerange=3%3A4&patch=&revcount=120">more</a>
-  |  </div>
+  | </div>
   
   <table class="bigtable">
   <thead>
@@ -1500,7 +1500,7 @@  filelog with 'linerange' and 'patch'
   <div class="navigate">
   <a href="/log/tip/c?linerange=3%3A4&patch=&revcount=30">less</a>
   <a href="/log/tip/c?linerange=3%3A4&patch=&revcount=120">more</a>
-  |  
+  | 
   </div>
   
   </div>
@@ -1651,7 +1651,7 @@  filelog with 'linerange' and 'patch'
   <div class="navigate">
   <a href="/log/8/c?descend=&linerange=3%3A4&revcount=30">less</a>
   <a href="/log/8/c?descend=&linerange=3%3A4&revcount=120">more</a>
-  |  </div>
+  | </div>
   
   <table class="bigtable">
   <thead>
@@ -1696,7 +1696,7 @@  filelog with 'linerange' and 'patch'
   <div class="navigate">
   <a href="/log/8/c?descend=&linerange=3%3A4&revcount=30">less</a>
   <a href="/log/8/c?descend=&linerange=3%3A4&revcount=120">more</a>
-  |  
+  | 
   </div>
   
   </div>