Patchwork [6,of,8,V2] hgweb: link to diff with linerange in filelog template

login
register
mail settings
Submitter Denis Laxalde
Date Feb. 25, 2017, 9:06 a.m.
Message ID <206b34cf11b768c4e745.1488013563@marimba>
Download mbox | patch
Permalink /patch/18779/
State Changes Requested
Headers show

Comments

Denis Laxalde - Feb. 25, 2017, 9:06 a.m.
# HG changeset patch
# User Denis Laxalde <denis.laxalde@logilab.fr>
# Date 1484838729 -3600
#      Thu Jan 19 16:12:09 2017 +0100
# Node ID 206b34cf11b768c4e74582ffb89e78feedbce7ef
# Parent  7fbe70c91d65683ab3984f7c80edc85f5c02860c
# Available At https://hg.logilab.org/users/dlaxalde/hg
#              hg pull https://hg.logilab.org/users/dlaxalde/hg -r 206b34cf11b7
# 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.)
Gregory Szorc - Feb. 28, 2017, 11:28 p.m.
On Sat, Feb 25, 2017 at 1:06 AM, Denis Laxalde <denis@laxalde.org> wrote:

> # HG changeset patch
> # User Denis Laxalde <denis.laxalde@logilab.fr>
> # Date 1484838729 -3600
> #      Thu Jan 19 16:12:09 2017 +0100
> # Node ID 206b34cf11b768c4e74582ffb89e78feedbce7ef
> # Parent  7fbe70c91d65683ab3984f7c80edc85f5c02860c
> # Available At https://hg.logilab.org/users/dlaxalde/hg
> #              hg pull https://hg.logilab.org/users/dlaxalde/hg -r
> 206b34cf11b7
> # 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.)
>
> 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> |
>

{linerange} needs escaped because ':' is a reserved character in URLs. It
should be encoded as %3A in the HTML.


>        <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>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>

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>