Patchwork [2,of,4] gitweb: add links to diff and changeset views from annotate view table

login
register
mail settings
Submitter Denis Laxalde
Date June 6, 2016, 8:03 a.m.
Message ID <632a34ed3b63420e1444.1465200198@sh77.tls.logilab.fr>
Download mbox | patch
Permalink /patch/15421/
State Changes Requested
Headers show

Comments

Denis Laxalde - June 6, 2016, 8:03 a.m.
# HG changeset patch
# User Denis Laxalde <denis.laxalde@logilab.fr>
# Date 1464883191 -7200
#      Thu Jun 02 17:59:51 2016 +0200
# Node ID 632a34ed3b63420e1444cb4c3a09a0692b274615
# Parent  506891a0db9f74ec9fee2c0bd3a7ed6af12eb83b
gitweb: add links to diff and changeset views from annotate view table
Anton Shestakov - June 6, 2016, 9 a.m.
06.06.2016, 16:09, "Denis Laxalde" <denis.laxalde@logilab.fr>:
> # HG changeset patch
> # User Denis Laxalde <denis.laxalde@logilab.fr>
> # Date 1464883191 -7200
> # Thu Jun 02 17:59:51 2016 +0200
> # Node ID 632a34ed3b63420e1444cb4c3a09a0692b274615
> # Parent 506891a0db9f74ec9fee2c0bd3a7ed6af12eb83b
> gitweb: add links to diff and changeset views from annotate view table
>
> diff --git a/mercurial/templates/gitweb/map b/mercurial/templates/gitweb/map
> --- a/mercurial/templates/gitweb/map
> +++ b/mercurial/templates/gitweb/map
> @@ -100,6 +100,12 @@ annotateline = '
>        <a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#l{targetline}"
>           title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a>
>      </td>
> + <td>
> + <a href="{url|urlescape}diff/{node|short}/{file|urlescape}{sessionvars%urlparameter}#l{targetline}"
> + title="diff">diff</a>
> + <a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}"
> + title="rev">rev</a>
> + </td>

In the diff link, #l{targetline} will not work as intended, for two reasons:

1. diffs can contain multiple files and so line links are referred by id="l<filenumber>.<linenumber>". Hard-coding file number to always be 1 (after all it's a diff for one file) also wouldn't work because
2. targetline is not the line number in a diff, it's a line number in the file

Another thing: title attributes could be a lot clearer, because right now they just duplicate text content, and so are totally useless. Look at the original link above your changes; it has useful things in its title, like node hash and the first line of commit message.

Here's an informative example of rev title: "mercurial/templates/gitweb/map@632a34ed3b63".

Patch

diff --git a/mercurial/templates/gitweb/map b/mercurial/templates/gitweb/map
--- a/mercurial/templates/gitweb/map
+++ b/mercurial/templates/gitweb/map
@@ -100,6 +100,12 @@  annotateline = '
       <a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#l{targetline}"
          title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a>
     </td>
+    <td>
+      <a href="{url|urlescape}diff/{node|short}/{file|urlescape}{sessionvars%urlparameter}#l{targetline}"
+         title="diff">diff</a>
+      <a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}"
+         title="rev">rev</a>
+    </td>
     <td><pre><a class="linenr" href="#{lineid}">{linenumber}</a></pre></td>
     <td><pre>{line|escape}</pre></td>
   </tr>'
diff --git a/tests/test-hgweb-symrev.t b/tests/test-hgweb-symrev.t
--- a/tests/test-hgweb-symrev.t
+++ b/tests/test-hgweb-symrev.t
@@ -617,7 +617,11 @@  Set up the repo
   <a class="list" href="/annotate/43c799df6e75/foo?style=gitweb">
   <a class="list" href="/annotate/9d8c40cba617/foo?style=gitweb">9d8c40cba617</a></td>
   <a href="/annotate/43c799df6e75/foo?style=gitweb#l1"
+  <a href="/diff/43c799df6e75/foo?style=gitweb#l1"
+  <a href="/rev/43c799df6e75?style=gitweb"
   <a href="/annotate/a7c1559b7bba/foo?style=gitweb#l2"
+  <a href="/diff/a7c1559b7bba/foo?style=gitweb#l2"
+  <a href="/rev/a7c1559b7bba?style=gitweb"
 
   $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT 'diff/xyzzy/foo?style=gitweb' | egrep $REVLINKS
   <a href="/file/xyzzy?style=gitweb">files</a> |