Patchwork [2,of,5] hgweb: avoid invalid infinity scroll request when overwritten web.style

login
register
mail settings
Submitter Takumi IINO
Date Jan. 7, 2014, 3:52 p.m.
Message ID <7a6741c42018ae560f03.1389109935@iinotakken-no-MacBook-Air.local>
Download mbox | patch
Permalink /patch/3267/
State Accepted
Headers show

Comments

Takumi IINO - Jan. 7, 2014, 3:52 p.m.
# HG changeset patch
# User Takumi IINO <trot.thunder@gmail.com>
# Date 1389108903 -32400
#      Wed Jan 08 00:35:03 2014 +0900
# Node ID 7a6741c42018ae560f031be991a64fface19f8d2
# Parent  2125063139b05aac4aa7cff2bfd6b334aee8cfc4
hgweb: avoid invalid infinity scroll request when overwritten web.style

Infinity scroll is broken when you override the web.style in the following ways:

    $ hg --config='web.style=gitweb' serve
    $ open http://localhost:8080/shortlog?style=paper

ajaxScrollInit should use http://localhost:8080/shortlog/%next%?style=paper.
however, http://localhost:8080/shortlog/%next% is used actually.
It is missing style parameter.

This patch add style parameter to request url.

Patch

diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py
+++ b/mercurial/hgweb/hgweb_mod.py
@@ -371,10 +371,11 @@  class hgweb(object):
                                              "repo": self.reponame,
                                              "encoding": encoding.encoding,
                                              "motd": motd,
                                              "sessionvars": sessionvars,
                                              "pathdef": makebreadcrumb(req.url),
+                                             "style": style,
                                             })
         return tmpl
 
     def archivelist(self, nodeid):
         allowed = self.configlist("web", "allow_archive")
diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py
--- a/mercurial/hgweb/hgwebdir_mod.py
+++ b/mercurial/hgweb/hgwebdir_mod.py
@@ -446,11 +446,13 @@  class hgwebdir(object):
                                              "motd": motd,
                                              "url": url,
                                              "logourl": logourl,
                                              "logoimg": logoimg,
                                              "staticurl": staticurl,
-                                             "sessionvars": sessionvars})
+                                             "sessionvars": sessionvars,
+                                             "style": style,
+                                             })
         return tmpl
 
     def updatereqenv(self, env):
         if self._baseurl is not None:
             name, port, path = geturlcgivars(self._baseurl, env['SERVER_PORT'])
diff --git a/mercurial/templates/paper/graph.tmpl b/mercurial/templates/paper/graph.tmpl
--- a/mercurial/templates/paper/graph.tmpl
+++ b/mercurial/templates/paper/graph.tmpl
@@ -122,11 +122,11 @@  graph.render(data);
 | rev {rev}: {changenav%navgraph}
 </div>
 
 <script type="text/javascript">
     ajaxScrollInit(
-            '{url|urlescape}graph/{rev}?revcount=%next%',
+            '{url|urlescape}graph/{rev}?revcount=%next%&style={style}',
             {revcount}+60,
             function (htmlText, previousVal) \{ return previousVal + 60; },
             '#wrapper',
             '<div class="%class%" style="text-align: center;">%text%</div>',
             'graph'
diff --git a/mercurial/templates/paper/shortlog.tmpl b/mercurial/templates/paper/shortlog.tmpl
--- a/mercurial/templates/paper/shortlog.tmpl
+++ b/mercurial/templates/paper/shortlog.tmpl
@@ -71,11 +71,11 @@ 
 | rev {rev}: {changenav%navshort}
 </div>
 
 <script type="text/javascript">
     ajaxScrollInit(
-            '{url|urlescape}shortlog/%next%',
+            '{url|urlescape}shortlog/%next%{sessionvars%urlparameter}',
             '{nextentry%"{node}"}', <!-- NEXTHASH
             function (htmlText, previousVal) \{
                 var m = htmlText.match(/'(\w+)', <!-- NEXTHASH/);
                 return m ? m[1] : null;
             },
diff --git a/tests/test-hgweb-empty.t b/tests/test-hgweb-empty.t
--- a/tests/test-hgweb-empty.t
+++ b/tests/test-hgweb-empty.t
@@ -359,11 +359,11 @@  Some tests for hgweb in an empty reposit
   | rev -1: 
   </div>
   
   <script type="text/javascript">
       ajaxScrollInit(
-              '/graph/-1?revcount=%next%',
+              '/graph/-1?revcount=%next%&style=paper',
               60+60,
               function (htmlText, previousVal) { return previousVal + 60; },
               '#wrapper',
               '<div class="%class%" style="text-align: center;">%text%</div>',
               'graph'