[PATCH 3 of 3] hgweb: plug followlines action in annotate view

Denis Laxalde denis at laxalde.org
Thu Jun 22 10:40:12 EDT 2017


# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1498058237 -7200
#      Wed Jun 21 17:17:17 2017 +0200
# Node ID 3699fa6a226e7761c1624394b610c988dc1e8b69
# Parent  d568b7b353ea6d8ba9c30b1c2d976a88f2962245
# Available At http://hg.logilab.org/users/dlaxalde/hg
#              hg pull http://hg.logilab.org/users/dlaxalde/hg -r 3699fa6a226e
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).

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -865,6 +865,7 @@ def annotate(web, req, tmpl):
     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 @@ def annotate(web, req, tmpl):
                 symrev=webutil.symrevorshortnode(req, fctx),
                 rename=webutil.renamelink(fctx),
                 permissions=fctx.manifest().flags(f),
+                ishead=int(ishead),
                 **webutil.commonentry(web.repo, fctx))
 
 @webcommand('filelog')
diff --git a/mercurial/templates/gitweb/fileannotate.tmpl b/mercurial/templates/gitweb/fileannotate.tmpl
--- a/mercurial/templates/gitweb/fileannotate.tmpl
+++ b/mercurial/templates/gitweb/fileannotate.tmpl
@@ -66,10 +66,15 @@ annotate |
 </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}
diff --git a/mercurial/templates/paper/fileannotate.tmpl b/mercurial/templates/paper/fileannotate.tmpl
--- a/mercurial/templates/paper/fileannotate.tmpl
+++ b/mercurial/templates/paper/fileannotate.tmpl
@@ -73,7 +73,10 @@
  <th class="line">  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}
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
@@ -171,10 +171,12 @@ pre.sourcelines.stripes > span:target {
 }
 
 /* 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;
 }
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
@@ -280,10 +280,12 @@ td.annotate:hover div.annotate-info { di
   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;
 }
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: 8265
+  content-length: 8379
   content-type: text/css
   
   body { font-family: sans-serif; font-size: 12px; border:solid #d9d8d1; border-width:1px; margin:10px; background: white; color: black; }
@@ -516,10 +516,12 @@ static file
   }
   
   /* 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;
   }


More information about the Mercurial-devel mailing list