hgweb: plug followlines action in annotate view
authorDenis Laxalde <denis.laxalde@logilab.fr>
Wed, 21 Jun 2017 17:17:17 +0200
changeset 32996 1c97df5e3b46
parent 32995 7c82bfd55d47
child 32997 b9e2269aeff8
hgweb: plug followlines action in annotate view Add the followlines.js script and corresponding parameters as data attribute on <tbody class="sourcelines"> element. Extend CSS rules so that they also match the DOM structure of annotate view. As previously, only address paper and gitweb styles (other styles do not have followlines at all).
mercurial/hgweb/webcommands.py
mercurial/templates/gitweb/fileannotate.tmpl
mercurial/templates/paper/fileannotate.tmpl
mercurial/templates/static/style-gitweb.css
mercurial/templates/static/style-paper.css
tests/test-hgweb.t
tests/test-highlight.t
--- a/mercurial/hgweb/webcommands.py	Wed Jun 21 17:07:51 2017 +0200
+++ b/mercurial/hgweb/webcommands.py	Wed Jun 21 17:17:17 2017 +0200
@@ -865,6 +865,7 @@
     fctx = webutil.filectx(web.repo, req)
     f = fctx.path()
     parity = paritygen(web.stripecount)
+    ishead = fctx.filerev() in fctx.filelog().headrevs()
 
     # parents() is called once per line and several lines likely belong to
     # same revision. So it is worth caching.
@@ -927,6 +928,7 @@
                 symrev=webutil.symrevorshortnode(req, fctx),
                 rename=webutil.renamelink(fctx),
                 permissions=fctx.manifest().flags(f),
+                ishead=int(ishead),
                 **webutil.commonentry(web.repo, fctx))
 
 @webcommand('filelog')
--- a/mercurial/templates/gitweb/fileannotate.tmpl	Wed Jun 21 17:07:51 2017 +0200
+++ b/mercurial/templates/gitweb/fileannotate.tmpl	Wed Jun 21 17:17:17 2017 +0200
@@ -66,10 +66,15 @@
 </div>
 <div class="page_body">
 <table>
-<tbody>
+<tbody class="sourcelines"
+       data-logurl="{url|urlescape}log/{symrev}/{file|urlescape}"
+       data-selectabletag="TR"
+       data-ishead="{ishead}">
 {annotate%annotateline}
 </tbody>
 </table>
 </div>
 
+<script type="text/javascript" src="{staticurl|urlescape}followlines.js"></script>
+
 {footer}
--- a/mercurial/templates/paper/fileannotate.tmpl	Wed Jun 21 17:07:51 2017 +0200
+++ b/mercurial/templates/paper/fileannotate.tmpl	Wed Jun 21 17:17:17 2017 +0200
@@ -73,7 +73,10 @@
  <th class="line">&nbsp;&nbsp;line source</th>
 </tr>
 </thead>
-<tbody class="stripes2">
+<tbody class="stripes2 sourcelines"
+       data-logurl="{url|urlescape}log/{symrev}/{file|urlescape}"
+       data-selectabletag="TR"
+       data-ishead="{ishead}">
   {annotate%annotateline}
 </tbody>
 </table>
@@ -81,4 +84,6 @@
 </div>
 </div>
 
+<script type="text/javascript" src="{staticurl|urlescape}followlines.js"></script>
+
 {footer}
--- a/mercurial/templates/static/style-gitweb.css	Wed Jun 21 17:07:51 2017 +0200
+++ b/mercurial/templates/static/style-gitweb.css	Wed Jun 21 17:17:17 2017 +0200
@@ -177,10 +177,12 @@
 }
 
 /* Followlines */
+div.page_body table tbody.sourcelines > tr.followlines-select:hover,
 div.page_body pre.sourcelines > span.followlines-select:hover {
   cursor: cell;
 }
 
+tbody.sourcelines > tr.followlines-selected,
 pre.sourcelines > span.followlines-selected {
   background-color: #99C7E9 !important;
 }
--- a/mercurial/templates/static/style-paper.css	Wed Jun 21 17:07:51 2017 +0200
+++ b/mercurial/templates/static/style-paper.css	Wed Jun 21 17:17:17 2017 +0200
@@ -280,10 +280,12 @@
   background-color: #bfdfff;
 }
 
+div.overflow table tbody.sourcelines > tr.followlines-select:hover,
 div.overflow pre.sourcelines > span.followlines-select:hover {
   cursor: cell;
 }
 
+tbody.sourcelines > tr.followlines-selected,
 pre.sourcelines > span.followlines-selected {
   background-color: #99C7E9;
 }
--- a/tests/test-hgweb.t	Wed Jun 21 17:07:51 2017 +0200
+++ b/tests/test-hgweb.t	Wed Jun 21 17:17:17 2017 +0200
@@ -340,7 +340,7 @@
 
   $ get-with-headers.py --twice localhost:$HGPORT 'static/style-gitweb.css' - date etag server
   200 Script output follows
-  content-length: 8349
+  content-length: 8463
   content-type: text/css
   
   body { font-family: sans-serif; font-size: 12px; border:solid #d9d8d1; border-width:1px; margin:10px; background: white; color: black; }
@@ -522,10 +522,12 @@
   }
   
   /* Followlines */
+  div.page_body table tbody.sourcelines > tr.followlines-select:hover,
   div.page_body pre.sourcelines > span.followlines-select:hover {
     cursor: cell;
   }
   
+  tbody.sourcelines > tr.followlines-selected,
   pre.sourcelines > span.followlines-selected {
     background-color: #99C7E9 !important;
   }
--- a/tests/test-highlight.t	Wed Jun 21 17:07:51 2017 +0200
+++ b/tests/test-highlight.t	Wed Jun 21 17:17:17 2017 +0200
@@ -292,7 +292,10 @@
    <th class="line">&nbsp;&nbsp;line source</th>
   </tr>
   </thead>
-  <tbody class="stripes2">
+  <tbody class="stripes2 sourcelines"
+         data-logurl="/log/tip/primes.py"
+         data-selectabletag="TR"
+         data-ishead="1">
     
   <tr id="l1" class="thisrev">
   <td class="annotate parity0">
@@ -829,6 +832,8 @@
   </div>
   </div>
   
+  <script type="text/javascript" src="/static/followlines.js"></script>
+  
   
   
   </body>