Patchwork [3,of,4,V5] hgweb: add link to parents of annotated revision in annotate view

login
register
mail settings
Submitter Denis Laxalde
Date June 14, 2016, 12:53 p.m.
Message ID <ad269193c2590946f31d.1465908794@sh77.tls.logilab.fr>
Download mbox | patch
Permalink /patch/15503/
State Superseded
Headers show

Comments

Denis Laxalde - June 14, 2016, 12:53 p.m.
# HG changeset patch
# User Denis Laxalde <denis.laxalde@logilab.fr>
# Date 1465894453 -7200
#      Tue Jun 14 10:54:13 2016 +0200
# Node ID ad269193c2590946f31d7f86fbd85f06f6baacb4
# Parent  9e807bdf1626b228399c219e66c027233fa3b0d5
hgweb: add link to parents of annotated revision in annotate view

The link is embedded into a div with class="annotate-info" that only shows up
upon hover of the annotate column.
Anton Shestakov - June 14, 2016, 2:11 p.m.
14.06.2016, 20:53, "Denis Laxalde" <denis.laxalde@logilab.fr>:
>  # HG changeset patch
>  # User Denis Laxalde <denis.laxalde@logilab.fr>
>  # Date 1465894453 -7200
>  # Tue Jun 14 10:54:13 2016 +0200
>  # Node ID ad269193c2590946f31d7f86fbd85f06f6baacb4
>  # Parent 9e807bdf1626b228399c219e66c027233fa3b0d5
>  hgweb: add link to parents of annotated revision in annotate view
>
>  The link is embedded into a div with class="annotate-info" that only shows up
>  upon hover of the annotate column.

Since this patch is not obvious, I have some questions before seeing it in action (since it depends on the previous patches, and I hope we can accept them soon).

>  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
>  @@ -210,6 +210,16 @@ h3 {
>   .bigtable td.source { font-size: inherit; }
>   tr.thisrev a { color:#999999; text-decoration: none; }
>   tr.thisrev td.source { color:#009900; }
>  +div.annotate-info {
>  + display: none;
>  + position: absolute;

It's absolutely positioned relative to what? And where will it appear, since it doesn't specify any coordinates?

>  + background-color: #FFFFFF;
>  + border-color: #000000;
>  + border: 1px solid;

Nit: a shortcut is "border: 1px solid #000000;"

>  +}
>  +.annotate-info p {margin-top: 0; margin-bottom: 0;}

Nit: if it's a <p> that needs removing margins, can it just be a <div> instead?

>  +td.annotate:hover div.annotate-info { display: inline; text-align: left; color: #000000;}
>  +td.annotate:hover .annotate-info a { color: #0000FF; text-decoration: underline; }

I don't get these two. Setting display on hover is obvious, but why set things like color, text-align and text-decoration on hover only?
Denis Laxalde - June 14, 2016, 2:31 p.m.
Anton Shestakov a écrit :
> 14.06.2016, 20:53, "Denis Laxalde" <denis.laxalde@logilab.fr>:
>>   # HG changeset patch
>>   # User Denis Laxalde <denis.laxalde@logilab.fr>
>>   # Date 1465894453 -7200
>>   # Tue Jun 14 10:54:13 2016 +0200
>>   # Node ID ad269193c2590946f31d7f86fbd85f06f6baacb4
>>   # Parent 9e807bdf1626b228399c219e66c027233fa3b0d5
>>   hgweb: add link to parents of annotated revision in annotate view
>>
>>   The link is embedded into a div with class="annotate-info" that only shows up
>>   upon hover of the annotate column.
>
> Since this patch is not obvious, I have some questions before seeing it in action (since it depends on the previous patches, and I hope we can accept them soon).

hg pull https://bitbucket.org/dlax/hg-work -r 961683779514 if you want 
to see the series "in action".

>>   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
>>   @@ -210,6 +210,16 @@ h3 {
>>    .bigtable td.source { font-size: inherit; }
>>    tr.thisrev a { color:#999999; text-decoration: none; }
>>    tr.thisrev td.source { color:#009900; }
>>   +div.annotate-info {
>>   + display: none;
>>   + position: absolute;
>
> It's absolutely positioned relative to what? And where will it appear, since it doesn't specify any coordinates?

It'd positioned relative to the parent "td" element containing the link 
to annotated revision. Being absolutely positioned, it will not 
interfere with other elements position (otherwise, other elements would 
move around when that element is shown).

>>   + background-color: #FFFFFF;
>>   + border-color: #000000;
>>   + border: 1px solid;
>
> Nit: a shortcut is "border: 1px solid #000000;"
>
>>   +}
>>   +.annotate-info p {margin-top: 0; margin-bottom: 0;}
>
> Nit: if it's a <p> that needs removing margins, can it just be a <div> instead?

Very true.

>>   +td.annotate:hover div.annotate-info { display: inline; text-align: left; color: #000000;}
>>   +td.annotate:hover .annotate-info a { color: #0000FF; text-decoration: underline; }
>
> I don't get these two. Setting display on hover is obvious, but why set things like color, text-align and text-decoration on hover only?

True as well, will move these in the generic case.
Anton Shestakov - June 14, 2016, 3:35 p.m.
14.06.2016, 22:31, "Denis Laxalde" <denis.laxalde@logilab.fr>:
> Anton Shestakov a écrit :
>>  14.06.2016, 20:53, "Denis Laxalde" <denis.laxalde@logilab.fr>:
>>>    # HG changeset patch
>>>    # User Denis Laxalde <denis.laxalde@logilab.fr>
>>>    # Date 1465894453 -7200
>>>    # Tue Jun 14 10:54:13 2016 +0200
>>>    # Node ID ad269193c2590946f31d7f86fbd85f06f6baacb4
>>>    # Parent 9e807bdf1626b228399c219e66c027233fa3b0d5
>>>    hgweb: add link to parents of annotated revision in annotate view
>>>
>>>    The link is embedded into a div with class="annotate-info" that only shows up
>>>    upon hover of the annotate column.
>>
>>  Since this patch is not obvious, I have some questions before seeing it in action (since it depends on the previous patches, and I hope we can accept them soon).
>
> hg pull https://bitbucket.org/dlax/hg-work -r 961683779514 if you want
> to see the series "in action".

Thanks, looks alright.

>>>    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
>>>    @@ -210,6 +210,16 @@ h3 {
>>>     .bigtable td.source { font-size: inherit; }
>>>     tr.thisrev a { color:#999999; text-decoration: none; }
>>>     tr.thisrev td.source { color:#009900; }
>>>    +div.annotate-info {
>>>    + display: none;
>>>    + position: absolute;
>>
>>  It's absolutely positioned relative to what? And where will it appear, since it doesn't specify any coordinates?
>
> It'd positioned relative to the parent "td" element containing the link
> to annotated revision. Being absolutely positioned, it will not
> interfere with other elements position (otherwise, other elements would
> move around when that element is shown).

Actually, it's relative to whatever the first parent element with "position: relative;" is (in case of paper, it's the .main block). You can see that if you add any coordinate to the .annotate-info, like "top: 0;" (that would make it fly off to the top of the screen).

That's just so you know, because right now it seems to look fine, so I have no problem with this.

Patch

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -863,6 +863,16 @@  def annotate(web, req, tmpl):
     diffopts = patch.difffeatureopts(web.repo.ui, untrusted=True,
                                      section='annotate', whitespace=True)
 
+    def parents(f):
+        for p in f.parents():
+            yield {
+                "node": p.hex(),
+                "rev": p.rev(),
+                "author": p.user(),
+                "desc": p.description(),
+                "file": p.path(),
+            }
+
     def annotate(**map):
         if util.binary(fctx.data()):
             mt = (mimetypes.guess_type(fctx.path())[0]
@@ -881,6 +891,7 @@  def annotate(web, req, tmpl):
                    "node": f.hex(),
                    "rev": rev,
                    "author": f.user(),
+                   "parents": parents(f),
                    "desc": f.description(),
                    "extra": f.extra(),
                    "file": f.path(),
diff --git a/mercurial/templates/gitweb/map b/mercurial/templates/gitweb/map
--- a/mercurial/templates/gitweb/map
+++ b/mercurial/templates/gitweb/map
@@ -96,15 +96,21 @@  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}{ifeq(node, originalnode, ' thisrev', '')}">
-    <td class="linenr" style="text-align: right;">
+    <td class="annotate linenr" style="text-align: right;">
       {if(blockhead,
           '<a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#l{targetline}"
-              title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a>',
+              title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a>
+           <div class="annotate-info">
+              {parents%annotateparent}
+           </div>',
           '')}
     </td>
     <td><pre><a class="linenr" href="#{lineid}">{linenumber}</a></pre></td>
     <td><pre>{line|escape}</pre></td>
   </tr>'
+annotateparent = '
+  <p>parent: <a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}"
+                title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a></p>'
 difflineplus = '
   <a href="#{lineid}"></a><span id="{lineid}" class="difflineplus">{strip(line|escape, '\r\n')}</span>'
 difflineminus = '
diff --git a/mercurial/templates/monoblue/map b/mercurial/templates/monoblue/map
--- a/mercurial/templates/monoblue/map
+++ b/mercurial/templates/monoblue/map
@@ -92,10 +92,13 @@  fileline = '
   <a href="#{lineid}"></a><span id="{lineid}">{strip(line|escape, '\r\n')}</span>'
 annotateline = '
   <tr id="{lineid}" class="parity{parity}{ifeq(node, originalnode, ' thisrev', '')}">
-    <td class="linenr">
+    <td class="annotate linenr">
       {if(blockhead,
           '<a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#l{targetline}"
-              title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a>',
+              title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a>
+           <div class="annotate-info">
+             {parents%annotateparent}
+           </div>',
           '')}
     </td>
     <td class="lineno">
@@ -103,6 +106,9 @@  annotateline = '
     </td>
     <td class="source">{line|escape}</td>
   </tr>'
+annotateparent = '
+  <p>parent: <a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}"
+                title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a></p>'
 difflineplus = '
   <a href="#{lineid}"></a><span id="{lineid}" class="difflineplus">{strip(line|escape, '\r\n')}</span>'
 difflineminus = '
diff --git a/mercurial/templates/paper/map b/mercurial/templates/paper/map
--- a/mercurial/templates/paper/map
+++ b/mercurial/templates/paper/map
@@ -80,12 +80,17 @@  annotateline = '
     <td class="annotate">
       {if(blockhead,
           '<a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#l{targetline}"
-              title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a>',
+              title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a>
+           <div class="annotate-info">
+             {parents%annotateparent}
+           </div>',
           '')}
     </td>
     <td class="source"><a href="#{lineid}">{linenumber}</a> {line|escape}</td>
   </tr>'
-
+annotateparent = '
+  <p>parent: <a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}"
+                title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a></p>'
 diffblock = '<div class="bottomline inc-lineno"><pre class="sourcelines wrap">{lines}</pre></div>'
 difflineplus = '
   <span id="{lineid}" class="plusline">{strip(line|escape, '\r\n')}</span><a href="#{lineid}"></a>'
diff --git a/mercurial/templates/spartan/map b/mercurial/templates/spartan/map
--- a/mercurial/templates/spartan/map
+++ b/mercurial/templates/spartan/map
@@ -58,7 +58,10 @@  annotateline = '
     <td class="annotate">
       {if(blockhead,
           '<a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#l{targetline}"
-              title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a>',
+              title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a>
+           <div class="annotate-info">
+             {parents%annotateparent}
+           </div>',
           '')}
     </td>
     <td>
@@ -66,6 +69,9 @@  annotateline = '
     </td>
     <td><pre>&nbsp;{line|escape}</pre></td>
   </tr>'
+annotateparent = '
+  <p>parent: <a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}"
+                title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a></p>'
 difflineplus = '<span class="plusline"><a class="lineno" href="#{lineid}" id="{lineid}">{linenumber}</a>{line|escape}</span>'
 difflineminus = '<span class="minusline"><a class="lineno" href="#{lineid}" id="{lineid}">{linenumber}</a>{line|escape}</span>'
 difflineat = '<span class="atline"><a class="lineno" href="#{lineid}" id="{lineid}">{linenumber}</a>{line|escape}</span>'
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
@@ -54,6 +54,16 @@  div.index_include { border:solid #d9d8d1
 div.search { margin:4px 8px; position:absolute; top:56px; right:12px }
 tr.thisrev a { color:#999999; text-decoration: none; }
 tr.thisrev pre { color:#009900; }
+div.annotate-info {
+  display: none;
+  position: absolute;
+  background-color: #FFFFFF;
+  border-color: #000000;
+  border: 1px solid;
+}
+.annotate-info p {margin-top: 0; margin-bottom: 0;}
+td.annotate:hover div.annotate-info { display: block; text-align: left; color: #000000;}
+td.annotate:hover .annotate-info a { color: #0000FF; text-decoration: underline; }
 .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
@@ -333,6 +333,15 @@  td.linenr {
 }
 tr.thisrev a { color:#999999; text-decoration: none; }
 tr.thisrev td.source { color:#009900; }
+div.annotate-info {
+  display: none;
+  position: absolute;
+  background-color: #FFFFFF;
+  border-color: #000000;
+  border: 1px solid;
+}
+td.annotate:hover div.annotate-info { display: block; text-align: left; color: #000000;}
+td.annotate:hover .annotate-info a { color: #0000FF; text-decoration: underline; }
 
 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
@@ -210,6 +210,16 @@  h3 {
 .bigtable td.source { font-size: inherit; }
 tr.thisrev a { color:#999999; text-decoration: none; }
 tr.thisrev td.source { color:#009900; }
+div.annotate-info {
+  display: none;
+  position: absolute;
+  background-color: #FFFFFF;
+  border-color: #000000;
+  border: 1px solid;
+}
+.annotate-info p {margin-top: 0; margin-bottom: 0;}
+td.annotate:hover div.annotate-info { display: inline; text-align: left; color: #000000;}
+td.annotate:hover .annotate-info a { color: #0000FF; text-decoration: underline; }
 
 .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
@@ -12,6 +12,16 @@  a { text-decoration:none; }
 .annotate { font-size: smaller; text-align: right; padding-right: 1em; }
 tr.thisrev a { color:#999999; text-decoration: none; }
 tr.thisrev pre { color:#009900; }
+div.annotate-info {
+  display: none;
+  position: absolute;
+  background-color: #FFFFFF;
+  border-color: #000000;
+  border: 1px solid;
+}
+.annotate-info p {margin-top: 0; margin-bottom: 0;}
+td.annotate:hover div.annotate-info { display: block; text-align: left; color: #000000;}
+td.annotate:hover .annotate-info a { color: #0000FF; text-decoration: underline; }
 .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
@@ -1959,6 +1959,16 @@  Static files
   .annotate { font-size: smaller; text-align: right; padding-right: 1em; }
   tr.thisrev a { color:#999999; text-decoration: none; }
   tr.thisrev pre { color:#009900; }
+  div.annotate-info {
+    display: none;
+    position: absolute;
+    background-color: #FFFFFF;
+    border-color: #000000;
+    border: 1px solid;
+  }
+  .annotate-info p {margin-top: 0; margin-bottom: 0;}
+  td.annotate:hover div.annotate-info { display: block; text-align: left; color: #000000;}
+  td.annotate:hover .annotate-info a { color: #0000FF; text-decoration: underline; }
   .buttons a {
     background-color: #666;
     padding: 2pt;
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
@@ -192,6 +192,7 @@  Set up the repo
    <td class="author"><a href="/file/9d8c40cba617/foo?style=paper">9d8c40cba617</a> </td>
   <a href="/annotate/43c799df6e75/foo?style=paper#l1"
   <a href="/annotate/a7c1559b7bba/foo?style=paper#l2"
+  <p>parent: <a href="/annotate/43c799df6e75/foo?style=paper"
 
   $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT 'diff/xyzzy/foo?style=paper' | egrep $REVLINKS
   <li><a href="/shortlog/xyzzy?style=paper">log</a></li>
@@ -380,6 +381,7 @@  Set up the repo
    <td class="author"><a href="/file/9d8c40cba617/foo?style=coal">9d8c40cba617</a> </td>
   <a href="/annotate/43c799df6e75/foo?style=coal#l1"
   <a href="/annotate/a7c1559b7bba/foo?style=coal#l2"
+  <p>parent: <a href="/annotate/43c799df6e75/foo?style=coal"
 
   $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT 'diff/xyzzy/foo?style=coal' | egrep $REVLINKS
   <li><a href="/shortlog/xyzzy?style=coal">log</a></li>
@@ -618,6 +620,7 @@  Set up the repo
   <a class="list" href="/annotate/9d8c40cba617/foo?style=gitweb">9d8c40cba617</a></td>
   <a href="/annotate/43c799df6e75/foo?style=gitweb#l1"
   <a href="/annotate/a7c1559b7bba/foo?style=gitweb#l2"
+  <p>parent: <a href="/annotate/43c799df6e75/foo?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> |
@@ -834,6 +837,7 @@  Set up the repo
   <a href="/annotate/9d8c40cba617/foo?style=monoblue">9d8c40cba617</a>
   <a href="/annotate/43c799df6e75/foo?style=monoblue#l1"
   <a href="/annotate/a7c1559b7bba/foo?style=monoblue#l2"
+  <p>parent: <a href="/annotate/43c799df6e75/foo?style=monoblue"
 
   $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT 'diff/xyzzy/foo?style=monoblue' | egrep $REVLINKS
               <li><a href="/graph/xyzzy?style=monoblue">graph</a></li>
@@ -1031,6 +1035,7 @@  Set up the repo
   <td><a href="/annotate/9d8c40cba617/foo?style=spartan">9d8c40cba617</a></td>
   <a href="/annotate/43c799df6e75/foo?style=spartan#l1"
   <a href="/annotate/a7c1559b7bba/foo?style=spartan#l2"
+  <p>parent: <a href="/annotate/43c799df6e75/foo?style=spartan"
 
   $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT 'diff/xyzzy/foo?style=spartan' | egrep $REVLINKS
   <a href="/log/xyzzy?style=spartan">changelog</a>
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: 6610
+  content-length: 6970
   content-type: text/css
   
   body { font-family: sans-serif; font-size: 12px; border:solid #d9d8d1; border-width:1px; margin:10px; background: white; color: black; }
@@ -399,6 +399,16 @@  static file
   div.search { margin:4px 8px; position:absolute; top:56px; right:12px }
   tr.thisrev a { color:#999999; text-decoration: none; }
   tr.thisrev pre { color:#009900; }
+  div.annotate-info {
+    display: none;
+    position: absolute;
+    background-color: #FFFFFF;
+    border-color: #000000;
+    border: 1px solid;
+  }
+  .annotate-info p {margin-top: 0; margin-bottom: 0;}
+  td.annotate:hover div.annotate-info { display: block; text-align: left; color: #000000;}
+  td.annotate:hover .annotate-info a { color: #0000FF; text-decoration: underline; }
   .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
@@ -292,6 +292,9 @@  hgweb fileannotate, html
   <td class="annotate">
   <a href="/annotate/06824edf55d0/primes.py#l1"
   title="06824edf55d0: a">test@0</a>
+  <div class="annotate-info">
+  
+  </div>
   </td>
   <td class="source"><a href="#l1">     1</a> <span class="c">#!/usr/bin/env python</span></td>
   </tr>