[PATCH 1 of 4 V6] hgweb: highlight data of the current revision in annotate view

Denis Laxalde denis.laxalde at logilab.fr
Thu Jun 16 13:58:16 UTC 2016


# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1464877610 -7200
#      Thu Jun 02 16:26:50 2016 +0200
# Node ID 6ef96d3a3dc685edabc0f5ef653c31d9fece2916
# Parent  60621cecc8c53d3a27e9984fb06fefc1f99797b3
hgweb: highlight data of the current revision in annotate view

* Distinguish the /annotate/<revision>/<file>#<linenumber> link when it would
  lead to the current page (i.e. <revision> is the current revision) (style it
  gray and undecorated). This indicates more clearly that this is a "dead-end"
  in blame navigation.

* Display lines changed in current revision in green.

diff --git a/mercurial/templates/gitweb/map b/mercurial/templates/gitweb/map
--- a/mercurial/templates/gitweb/map
+++ b/mercurial/templates/gitweb/map
@@ -95,7 +95,7 @@ filelog = filelog.tmpl
 fileline = '
   <a href="#{lineid}"></a><span id="{lineid}">{strip(line|escape, '\r\n')}</span>'
 annotateline = '
-  <tr id="{lineid}" style="font-family:monospace" class="parity{parity}">
+  <tr id="{lineid}" style="font-family:monospace" class="parity{parity}{ifeq(node, originalnode, ' thisrev')}">
     <td class="linenr" style="text-align: right;">
       <a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#l{targetline}"
          title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a>
diff --git a/mercurial/templates/monoblue/map b/mercurial/templates/monoblue/map
--- a/mercurial/templates/monoblue/map
+++ b/mercurial/templates/monoblue/map
@@ -91,7 +91,7 @@ filelog = filelog.tmpl
 fileline = '
   <a href="#{lineid}"></a><span id="{lineid}">{strip(line|escape, '\r\n')}</span>'
 annotateline = '
-  <tr id="{lineid}" class="parity{parity}">
+  <tr id="{lineid}" class="parity{parity}{ifeq(node, originalnode, ' thisrev')}">
     <td class="linenr">
       <a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#l{targetline}"
          title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a>
diff --git a/mercurial/templates/paper/map b/mercurial/templates/paper/map
--- a/mercurial/templates/paper/map
+++ b/mercurial/templates/paper/map
@@ -76,7 +76,7 @@ fileline = '
 filelogentry = filelogentry.tmpl
 
 annotateline = '
-  <tr id="{lineid}">
+  <tr id="{lineid}"{ifeq(node, originalnode, ' class="thisrev"')}>
     <td class="annotate">
       <a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#l{targetline}"
          title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a>
diff --git a/mercurial/templates/spartan/map b/mercurial/templates/spartan/map
--- a/mercurial/templates/spartan/map
+++ b/mercurial/templates/spartan/map
@@ -54,7 +54,7 @@ filelogentry = filelogentry.tmpl
 # is an empty line in the annotated file), which in turn ensures that
 # all table rows have equal height.
 annotateline = '
-  <tr class="parity{parity}">
+  <tr class="parity{parity}{ifeq(node, originalnode, ' thisrev')}">
     <td class="annotate">
       <a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#l{targetline}"
          title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a>
diff --git a/mercurial/templates/static/style-gitweb.css b/mercurial/templates/static/style-gitweb.css
--- a/mercurial/templates/static/style-gitweb.css
+++ b/mercurial/templates/static/style-gitweb.css
@@ -52,6 +52,8 @@ div.pre { font-family:monospace; font-si
 div.diff_info { font-family:monospace; color:#000099; background-color:#edece6; font-style:italic; }
 div.index_include { border:solid #d9d8d1; border-width:0px 0px 1px; padding:12px 8px; }
 div.search { margin:4px 8px; position:absolute; top:56px; right:12px }
+tr.thisrev a { color:#999999; text-decoration: none; }
+tr.thisrev pre { color:#009900; }
 .linenr { color:#999999; text-decoration:none }
 div.rss_logo { float: right; white-space: nowrap; }
 div.rss_logo a {
diff --git a/mercurial/templates/static/style-monoblue.css b/mercurial/templates/static/style-monoblue.css
--- a/mercurial/templates/static/style-monoblue.css
+++ b/mercurial/templates/static/style-monoblue.css
@@ -331,6 +331,8 @@ td.source {
 td.linenr {
   width: 60px;
 }
+tr.thisrev a { color:#999999; text-decoration: none; }
+tr.thisrev td.source { color:#009900; }
 
 div#powered-by {
   position: absolute;
diff --git a/mercurial/templates/static/style-paper.css b/mercurial/templates/static/style-paper.css
--- a/mercurial/templates/static/style-paper.css
+++ b/mercurial/templates/static/style-paper.css
@@ -208,6 +208,8 @@ h3 {
 .bigtable .annotate { text-align: right; }
 .bigtable td.annotate { font-size: smaller; }
 .bigtable td.source { font-size: inherit; }
+tr.thisrev a { color:#999999; text-decoration: none; }
+tr.thisrev td.source { color:#009900; }
 
 .source, .sourcefirst {
   font-family: monospace;
diff --git a/mercurial/templates/static/style.css b/mercurial/templates/static/style.css
--- a/mercurial/templates/static/style.css
+++ b/mercurial/templates/static/style.css
@@ -10,6 +10,8 @@ a { text-decoration:none; }
 .minusline { color: red; }
 .atline { color: purple; }
 .annotate { font-size: smaller; text-align: right; padding-right: 1em; }
+tr.thisrev a { color:#999999; text-decoration: none; }
+tr.thisrev pre { color:#009900; }
 .buttons a {
   background-color: #666;
   padding: 2pt;
diff --git a/tests/test-hgweb-commands.t b/tests/test-hgweb-commands.t
--- a/tests/test-hgweb-commands.t
+++ b/tests/test-hgweb-commands.t
@@ -1957,6 +1957,8 @@ Static files
   .minusline { color: red; }
   .atline { color: purple; }
   .annotate { font-size: smaller; text-align: right; padding-right: 1em; }
+  tr.thisrev a { color:#999999; text-decoration: none; }
+  tr.thisrev pre { color:#009900; }
   .buttons a {
     background-color: #666;
     padding: 2pt;
diff --git a/tests/test-hgweb.t b/tests/test-hgweb.t
--- a/tests/test-hgweb.t
+++ b/tests/test-hgweb.t
@@ -340,7 +340,7 @@ static file
 
   $ get-with-headers.py --twice localhost:$HGPORT 'static/style-gitweb.css' - date etag server
   200 Script output follows
-  content-length: 6521
+  content-length: 6610
   content-type: text/css
   
   body { font-family: sans-serif; font-size: 12px; border:solid #d9d8d1; border-width:1px; margin:10px; background: white; color: black; }
@@ -397,6 +397,8 @@ static file
   div.diff_info { font-family:monospace; color:#000099; background-color:#edece6; font-style:italic; }
   div.index_include { border:solid #d9d8d1; border-width:0px 0px 1px; padding:12px 8px; }
   div.search { margin:4px 8px; position:absolute; top:56px; right:12px }
+  tr.thisrev a { color:#999999; text-decoration: none; }
+  tr.thisrev pre { color:#009900; }
   .linenr { color:#999999; text-decoration:none }
   div.rss_logo { float: right; white-space: nowrap; }
   div.rss_logo a {
diff --git a/tests/test-highlight.t b/tests/test-highlight.t
--- a/tests/test-highlight.t
+++ b/tests/test-highlight.t
@@ -288,231 +288,231 @@ hgweb fileannotate, html
   </thead>
   <tbody class="stripes2">
     
-  <tr id="l1">
+  <tr id="l1" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l1"
   title="06824edf55d0: a">test at 0</a>
   </td>
   <td class="source"><a href="#l1">     1</a> <span class="c">#!/usr/bin/env python</span></td>
   </tr>
-  <tr id="l2">
+  <tr id="l2" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l2"
   title="06824edf55d0: a">test at 0</a>
   </td>
   <td class="source"><a href="#l2">     2</a> </td>
   </tr>
-  <tr id="l3">
+  <tr id="l3" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l3"
   title="06824edf55d0: a">test at 0</a>
   </td>
   <td class="source"><a href="#l3">     3</a> <span class="sd">"""Fun with generators. Corresponding Haskell implementation:</span></td>
   </tr>
-  <tr id="l4">
+  <tr id="l4" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l4"
   title="06824edf55d0: a">test at 0</a>
   </td>
   <td class="source"><a href="#l4">     4</a> </td>
   </tr>
-  <tr id="l5">
+  <tr id="l5" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l5"
   title="06824edf55d0: a">test at 0</a>
   </td>
   <td class="source"><a href="#l5">     5</a> <span class="sd">primes = 2 : sieve [3, 5..]</span></td>
   </tr>
-  <tr id="l6">
+  <tr id="l6" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l6"
   title="06824edf55d0: a">test at 0</a>
   </td>
   <td class="source"><a href="#l6">     6</a> <span class="sd">    where sieve (p:ns) = p : sieve [n | n <- ns, mod n p /= 0]</span></td>
   </tr>
-  <tr id="l7">
+  <tr id="l7" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l7"
   title="06824edf55d0: a">test at 0</a>
   </td>
   <td class="source"><a href="#l7">     7</a> <span class="sd">"""</span></td>
   </tr>
-  <tr id="l8">
+  <tr id="l8" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l8"
   title="06824edf55d0: a">test at 0</a>
   </td>
   <td class="source"><a href="#l8">     8</a> </td>
   </tr>
-  <tr id="l9">
+  <tr id="l9" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l9"
   title="06824edf55d0: a">test at 0</a>
   </td>
   <td class="source"><a href="#l9">     9</a> <span class="kn">from</span> <span class="nn">itertools</span> <span class="kn">import</span> <span class="n">dropwhile</span><span class="p">,</span> <span class="n">ifilter</span><span class="p">,</span> <span class="n">islice</span><span class="p">,</span> <span class="n">count</span><span class="p">,</span> <span class="n">chain</span></td>
   </tr>
-  <tr id="l10">
+  <tr id="l10" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l10"
   title="06824edf55d0: a">test at 0</a>
   </td>
   <td class="source"><a href="#l10">    10</a> </td>
   </tr>
-  <tr id="l11">
+  <tr id="l11" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l11"
   title="06824edf55d0: a">test at 0</a>
   </td>
   <td class="source"><a href="#l11">    11</a> <span class="kn">def</span> <span class="nf">primes</span><span class="p">():</span></td>
   </tr>
-  <tr id="l12">
+  <tr id="l12" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l12"
   title="06824edf55d0: a">test at 0</a>
   </td>
   <td class="source"><a href="#l12">    12</a>     <span class="sd">"""Generate all primes."""</span></td>
   </tr>
-  <tr id="l13">
+  <tr id="l13" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l13"
   title="06824edf55d0: a">test at 0</a>
   </td>
   <td class="source"><a href="#l13">    13</a>     <span class="kn">def</span> <span class="nf">sieve</span><span class="p">(</span><span class="n">ns</span><span class="p">):</span></td>
   </tr>
-  <tr id="l14">
+  <tr id="l14" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l14"
   title="06824edf55d0: a">test at 0</a>
   </td>
   <td class="source"><a href="#l14">    14</a>         <span class="n">p</span> <span class="o">=</span> <span class="n">ns</span><span class="o">.</span><span class="n">next</span><span class="p">()</span></td>
   </tr>
-  <tr id="l15">
+  <tr id="l15" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l15"
   title="06824edf55d0: a">test at 0</a>
   </td>
   <td class="source"><a href="#l15">    15</a>         <span class="c"># It is important to yield *here* in order to stop the</span></td>
   </tr>
-  <tr id="l16">
+  <tr id="l16" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l16"
   title="06824edf55d0: a">test at 0</a>
   </td>
   <td class="source"><a href="#l16">    16</a>         <span class="c"># infinite recursion.</span></td>
   </tr>
-  <tr id="l17">
+  <tr id="l17" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l17"
   title="06824edf55d0: a">test at 0</a>
   </td>
   <td class="source"><a href="#l17">    17</a>         <span class="kn">yield</span> <span class="n">p</span></td>
   </tr>
-  <tr id="l18">
+  <tr id="l18" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l18"
   title="06824edf55d0: a">test at 0</a>
   </td>
   <td class="source"><a href="#l18">    18</a>         <span class="n">ns</span> <span class="o">=</span> <span class="n">ifilter</span><span class="p">(</span><span class="kn">lambda</span> <span class="n">n</span><span class="p">:</span> <span class="n">n</span> <span class="o">%</span> <span class="n">p</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">,</span> <span class="n">ns</span><span class="p">)</span></td>
   </tr>
-  <tr id="l19">
+  <tr id="l19" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l19"
   title="06824edf55d0: a">test at 0</a>
   </td>
   <td class="source"><a href="#l19">    19</a>         <span class="kn">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="n">sieve</span><span class="p">(</span><span class="n">ns</span><span class="p">):</span></td>
   </tr>
-  <tr id="l20">
+  <tr id="l20" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l20"
   title="06824edf55d0: a">test at 0</a>
   </td>
   <td class="source"><a href="#l20">    20</a>             <span class="kn">yield</span> <span class="n">n</span></td>
   </tr>
-  <tr id="l21">
+  <tr id="l21" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l21"
   title="06824edf55d0: a">test at 0</a>
   </td>
   <td class="source"><a href="#l21">    21</a> </td>
   </tr>
-  <tr id="l22">
+  <tr id="l22" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l22"
   title="06824edf55d0: a">test at 0</a>
   </td>
   <td class="source"><a href="#l22">    22</a>     <span class="n">odds</span> <span class="o">=</span> <span class="n">ifilter</span><span class="p">(</span><span class="kn">lambda</span> <span class="n">i</span><span class="p">:</span> <span class="n">i</span> <span class="o">%</span> <span class="mi">2</span> <span class="o">==</span> <span class="mi">1</span><span class="p">,</span> <span class="n">count</span><span class="p">())</span></td>
   </tr>
-  <tr id="l23">
+  <tr id="l23" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l23"
   title="06824edf55d0: a">test at 0</a>
   </td>
   <td class="source"><a href="#l23">    23</a>     <span class="kn">return</span> <span class="n">chain</span><span class="p">([</span><span class="mi">2</span><span class="p">],</span> <span class="n">sieve</span><span class="p">(</span><span class="n">dropwhile</span><span class="p">(</span><span class="kn">lambda</span> <span class="n">n</span><span class="p">:</span> <span class="n">n</span> <span class="o"><</span> <span class="mi">3</span><span class="p">,</span> <span class="n">odds</span><span class="p">)))</span></td>
   </tr>
-  <tr id="l24">
+  <tr id="l24" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l24"
   title="06824edf55d0: a">test at 0</a>
   </td>
   <td class="source"><a href="#l24">    24</a> </td>
   </tr>
-  <tr id="l25">
+  <tr id="l25" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l25"
   title="06824edf55d0: a">test at 0</a>
   </td>
   <td class="source"><a href="#l25">    25</a> <span class="kn">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">"__main__"</span><span class="p">:</span></td>
   </tr>
-  <tr id="l26">
+  <tr id="l26" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l26"
   title="06824edf55d0: a">test at 0</a>
   </td>
   <td class="source"><a href="#l26">    26</a>     <span class="kn">import</span> <span class="nn">sys</span></td>
   </tr>
-  <tr id="l27">
+  <tr id="l27" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l27"
   title="06824edf55d0: a">test at 0</a>
   </td>
   <td class="source"><a href="#l27">    27</a>     <span class="kn">try</span><span class="p">:</span></td>
   </tr>
-  <tr id="l28">
+  <tr id="l28" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l28"
   title="06824edf55d0: a">test at 0</a>
   </td>
   <td class="source"><a href="#l28">    28</a>         <span class="n">n</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span></td>
   </tr>
-  <tr id="l29">
+  <tr id="l29" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l29"
   title="06824edf55d0: a">test at 0</a>
   </td>
   <td class="source"><a href="#l29">    29</a>     <span class="kn">except</span> <span class="p">(</span><span class="ne">ValueError</span><span class="p">,</span> <span class="ne">IndexError</span><span class="p">):</span></td>
   </tr>
-  <tr id="l30">
+  <tr id="l30" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l30"
   title="06824edf55d0: a">test at 0</a>
   </td>
   <td class="source"><a href="#l30">    30</a>         <span class="n">n</span> <span class="o">=</span> <span class="mi">10</span></td>
   </tr>
-  <tr id="l31">
+  <tr id="l31" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l31"
   title="06824edf55d0: a">test at 0</a>
   </td>
   <td class="source"><a href="#l31">    31</a>     <span class="n">p</span> <span class="o">=</span> <span class="n">primes</span><span class="p">()</span></td>
   </tr>
-  <tr id="l32">
+  <tr id="l32" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l32"
   title="06824edf55d0: a">test at 0</a>
   </td>
   <td class="source"><a href="#l32">    32</a>     <span class="kn">print</span> <span class="s">"The first </span><span class="si">%d</span><span class="s"> primes: </span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="nb">list</span><span class="p">(</span><span class="n">islice</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">n</span><span class="p">)))</span></td>
   </tr>
-  <tr id="l33">
+  <tr id="l33" class="thisrev">
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l33"
   title="06824edf55d0: a">test at 0</a>


More information about the Mercurial-devel mailing list