Patchwork [09,of,11] hgweb: link to diff with linerange in filelog template

login
register
mail settings
Submitter Denis Laxalde
Date Feb. 22, 2017, 3:10 p.m.
Message ID <2a5126051c337f38bd15.1487776203@sh77.tls.logilab.fr>
Download mbox | patch
Permalink /patch/18708/
State Accepted
Delegated to: Yuya Nishihara
Headers show

Comments

Denis Laxalde - Feb. 22, 2017, 3:10 p.m.
# HG changeset patch
# User Denis Laxalde <denis.laxalde@logilab.fr>
# Date 1484838729 -3600
#      Thu Jan 19 16:12:09 2017 +0100
# Node ID 2a5126051c337f38bd15862c3c5d96a83ab47acc
# Parent  39e3bd58cb1af11ba2fd0a1a74bb134711dfe718
# EXP-Topic linerange-log/hgweb-filelog
hgweb: link to diff with linerange in filelog template

When "linerange" query parameter is present on a filelog request, the "diff"
links in revision table rows will also have this parameter.

Not sure this is that good from a user experience point of view, maybe an
additional "block diff" link would be better.

(Still only the gitweb template is updated.)

Patch

diff --git a/mercurial/templates/gitweb/map b/mercurial/templates/gitweb/map
--- a/mercurial/templates/gitweb/map
+++ b/mercurial/templates/gitweb/map
@@ -293,7 +293,7 @@  filelogentry = '
     </td>
     <td class="link">
       <a href="{url|urlescape}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">file</a> |
-      <a href="{url|urlescape}diff/{node|short}/{file|urlescape}{sessionvars%urlparameter}">diff</a> |
+      <a href="{url|urlescape}diff/{node|short}/{file|urlescape}{sessionvars%urlparameter}{if(linerange, '{if(sessionvars, "&", "?")}linerange={linerange}')}">diff</a> |
       <a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}">annotate</a>
       {rename%filelogrename}
     </td>
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
@@ -726,7 +726,7 @@  before addition - error
   </td>
   <td class="link">
   <a href="/file/46c1a66bd8fc/c?style=gitweb">file</a> |
-  <a href="/diff/46c1a66bd8fc/c?style=gitweb">diff</a> |
+  <a href="/diff/46c1a66bd8fc/c?style=gitweb&linerange=1-2">diff</a> |
   <a href="/annotate/46c1a66bd8fc/c?style=gitweb">annotate</a>
   
   </td>
@@ -742,7 +742,7 @@  before addition - error
   </td>
   <td class="link">
   <a href="/file/6563da9dcf87/b?style=gitweb">file</a> |
-  <a href="/diff/6563da9dcf87/b?style=gitweb">diff</a> |
+  <a href="/diff/6563da9dcf87/b?style=gitweb&linerange=1-1">diff</a> |
   <a href="/annotate/6563da9dcf87/b?style=gitweb">annotate</a>
   
   </td>
@@ -826,7 +826,7 @@  before addition - error
   </td>
   <td class="link">
   <a href="/file/46c1a66bd8fc/c?revcount=1&style=gitweb">file</a> |
-  <a href="/diff/46c1a66bd8fc/c?revcount=1&style=gitweb">diff</a> |
+  <a href="/diff/46c1a66bd8fc/c?revcount=1&style=gitweb&linerange=1-2">diff</a> |
   <a href="/annotate/46c1a66bd8fc/c?revcount=1&style=gitweb">annotate</a>
   
   </td>