# HG changeset patch # User Denis Laxalde # Date 1467106962 -7200 # Node ID 9c37df3474859af03d1ea8d07e71514bc4ea7d23 # Parent 83147ff53112c436270f24fe5b3599024a0edaaa 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. To avoid duplicate hover-overs (this new one and the one coming from link's title), drop "title" attribute from a element and put it in the annotate-info element. diff -r 83147ff53112 -r 9c37df347485 mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py Mon Jul 11 13:53:35 2016 +0200 +++ b/mercurial/hgweb/webcommands.py Tue Jun 28 11:42:42 2016 +0200 @@ -864,6 +864,13 @@ 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(), + } + def annotate(**map): if util.binary(fctx.data()): mt = (mimetypes.guess_type(fctx.path())[0] @@ -882,6 +889,7 @@ "node": f.hex(), "rev": rev, "author": f.user(), + "parents": parents(f), "desc": f.description(), "extra": f.extra(), "file": f.path(), diff -r 83147ff53112 -r 9c37df347485 mercurial/templates/gitweb/map --- a/mercurial/templates/gitweb/map Mon Jul 11 13:53:35 2016 +0200 +++ b/mercurial/templates/gitweb/map Tue Jun 28 11:42:42 2016 +0200 @@ -96,15 +96,21 @@ {strip(line|escape, '\r\n')}' annotateline = ' - + {if(blockhead, - '{author|user}@{rev}', - '')} + ' + {author|user}@{rev} + ')} +
+
{node|short}: {desc|escape|firstline}
+
parents: {parents%annotateparent}
+
{linenumber}
{line|escape}
' +annotateparent = ' + {rev}' difflineplus = ' {strip(line|escape, '\r\n')}' difflineminus = ' diff -r 83147ff53112 -r 9c37df347485 mercurial/templates/monoblue/map --- a/mercurial/templates/monoblue/map Mon Jul 11 13:53:35 2016 +0200 +++ b/mercurial/templates/monoblue/map Tue Jun 28 11:42:42 2016 +0200 @@ -92,17 +92,23 @@ {strip(line|escape, '\r\n')}' annotateline = ' - + {if(blockhead, - '{author|user}@{rev}', - '')} + ' + {author|user}@{rev} + ')} +
+
{node|short}: {desc|escape|firstline}
+
parents: {parents%annotateparent}
+
{linenumber} {line|escape} ' +annotateparent = ' + {rev}' difflineplus = ' {strip(line|escape, '\r\n')}' difflineminus = ' diff -r 83147ff53112 -r 9c37df347485 mercurial/templates/paper/map --- a/mercurial/templates/paper/map Mon Jul 11 13:53:35 2016 +0200 +++ b/mercurial/templates/paper/map Tue Jun 28 11:42:42 2016 +0200 @@ -79,13 +79,18 @@ {if(blockhead, - '{author|user}@{rev}', - '')} + ' + {author|user}@{rev} + ')} +
+
{node|short}: {desc|escape|firstline}
+
parents: {parents%annotateparent}
+
{linenumber} {line|escape} ' - +annotateparent = ' + {rev}' diffblock = '
{lines}
' difflineplus = ' {strip(line|escape, '\r\n')}' diff -r 83147ff53112 -r 9c37df347485 mercurial/templates/spartan/map --- a/mercurial/templates/spartan/map Mon Jul 11 13:53:35 2016 +0200 +++ b/mercurial/templates/spartan/map Tue Jun 28 11:42:42 2016 +0200 @@ -57,15 +57,21 @@ {if(blockhead, - '{author|user}@{rev}', - '')} + ' + {author|user}@{rev} + ')} +
+
{node|short}: {desc|escape|firstline}
+
parents: {parents%annotateparent}
+
{linenumber}
 {line|escape}
' +annotateparent = ' + {rev}' difflineplus = '{linenumber}{line|escape}' difflineminus = '{linenumber}{line|escape}' difflineat = '{linenumber}{line|escape}' diff -r 83147ff53112 -r 9c37df347485 mercurial/templates/static/style-gitweb.css --- a/mercurial/templates/static/style-gitweb.css Mon Jul 11 13:53:35 2016 +0200 +++ b/mercurial/templates/static/style-gitweb.css Tue Jun 28 11:42:42 2016 +0200 @@ -54,6 +54,17 @@ 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: 1px solid #000000; + text-align: left; + color: #000000; + padding: 5px; +} +div.annotate-info a { color: #0000FF; text-decoration: underline; } +td.annotate:hover div.annotate-info { display: inline; } .linenr { color:#999999; text-decoration:none } div.rss_logo { float: right; white-space: nowrap; } div.rss_logo a { diff -r 83147ff53112 -r 9c37df347485 mercurial/templates/static/style-monoblue.css --- a/mercurial/templates/static/style-monoblue.css Mon Jul 11 13:53:35 2016 +0200 +++ b/mercurial/templates/static/style-monoblue.css Tue Jun 28 11:42:42 2016 +0200 @@ -333,6 +333,17 @@ } 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: 1px solid #000000; + text-align: left; + color: #000000; + padding: 5px; +} +div.annotate-info a { color: #0000FF; } +td.annotate:hover div.annotate-info { display: inline; } div#powered-by { position: absolute; diff -r 83147ff53112 -r 9c37df347485 mercurial/templates/static/style-paper.css --- a/mercurial/templates/static/style-paper.css Mon Jul 11 13:53:35 2016 +0200 +++ b/mercurial/templates/static/style-paper.css Tue Jun 28 11:42:42 2016 +0200 @@ -210,6 +210,17 @@ .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: 1px solid #000000; + text-align: left; + color: #000000; + padding: 5px; +} +div.annotate-info a { color: #0000FF; } +td.annotate:hover div.annotate-info { display: inline; } .source, .sourcefirst { font-family: monospace; diff -r 83147ff53112 -r 9c37df347485 mercurial/templates/static/style.css --- a/mercurial/templates/static/style.css Mon Jul 11 13:53:35 2016 +0200 +++ b/mercurial/templates/static/style.css Tue Jun 28 11:42:42 2016 +0200 @@ -12,6 +12,17 @@ .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: 1px solid #000000; + text-align: left; + color: #000000; + padding: 5px; +} +div.annotate-info a { color: #0000FF; } +td.annotate:hover div.annotate-info { display: inline; } .buttons a { background-color: #666; padding: 2pt; diff -r 83147ff53112 -r 9c37df347485 tests/test-hgweb-commands.t --- a/tests/test-hgweb-commands.t Mon Jul 11 13:53:35 2016 +0200 +++ b/tests/test-hgweb-commands.t Tue Jun 28 11:42:42 2016 +0200 @@ -1965,6 +1965,17 @@ .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: 1px solid #000000; + text-align: left; + color: #000000; + padding: 5px; + } + div.annotate-info a { color: #0000FF; } + td.annotate:hover div.annotate-info { display: inline; } .buttons a { background-color: #666; padding: 2pt; diff -r 83147ff53112 -r 9c37df347485 tests/test-hgweb-symrev.t --- a/tests/test-hgweb-symrev.t Mon Jul 11 13:53:35 2016 +0200 +++ b/tests/test-hgweb-symrev.t Tue Jun 28 11:42:42 2016 +0200 @@ -190,8 +190,9 @@ annotate foo @ 1:a7c1559b7bba 43c799df6e75 9d8c40cba617 - + + 0 $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT 'diff/xyzzy/foo?style=paper' | egrep $REVLINKS
  • log
  • @@ -378,8 +379,9 @@ annotate foo @ 1:a7c1559b7bba 43c799df6e75 9d8c40cba617 - + + 0 $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT 'diff/xyzzy/foo?style=coal' | egrep $REVLINKS
  • log
  • @@ -616,8 +618,9 @@ a7c1559b7bba 9d8c40cba617 - + + 0 $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT 'diff/xyzzy/foo?style=gitweb' | egrep $REVLINKS files | @@ -832,8 +835,9 @@
    a7c1559b7bba
    9d8c40cba617 - + + 0 $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT 'diff/xyzzy/foo?style=monoblue' | egrep $REVLINKS
  • graph
  • @@ -1029,8 +1033,9 @@ a7c1559b7bba 9d8c40cba617 - + + 0 $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT 'diff/xyzzy/foo?style=spartan' | egrep $REVLINKS changelog diff -r 83147ff53112 -r 9c37df347485 tests/test-hgweb.t --- a/tests/test-hgweb.t Mon Jul 11 13:53:35 2016 +0200 +++ b/tests/test-hgweb.t Tue Jun 28 11:42:42 2016 +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: 6610 + content-length: 6908 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,17 @@ 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: 1px solid #000000; + text-align: left; + color: #000000; + padding: 5px; + } + div.annotate-info a { color: #0000FF; text-decoration: underline; } + td.annotate:hover div.annotate-info { display: inline; } .linenr { color:#999999; text-decoration:none } div.rss_logo { float: right; white-space: nowrap; } div.rss_logo a { diff -r 83147ff53112 -r 9c37df347485 tests/test-highlight.t --- a/tests/test-highlight.t Mon Jul 11 13:53:35 2016 +0200 +++ b/tests/test-highlight.t Tue Jun 28 11:42:42 2016 +0200 @@ -290,200 +290,333 @@ - test@0 + + test@0 + +
    +
    06824edf55d0: a
    +
    parents:
    +
    1 #!/usr/bin/env python +
    +
    06824edf55d0: a
    +
    parents:
    +
    2 +
    +
    06824edf55d0: a
    +
    parents:
    +
    3 """Fun with generators. Corresponding Haskell implementation: +
    +
    06824edf55d0: a
    +
    parents:
    +
    4 +
    +
    06824edf55d0: a
    +
    parents:
    +
    5 primes = 2 : sieve [3, 5..] +
    +
    06824edf55d0: a
    +
    parents:
    +
    6 where sieve (p:ns) = p : sieve [n | n <- ns, mod n p /= 0] +
    +
    06824edf55d0: a
    +
    parents:
    +
    7 """ +
    +
    06824edf55d0: a
    +
    parents:
    +
    8 +
    +
    06824edf55d0: a
    +
    parents:
    +
    9 from itertools import dropwhile, ifilter, islice, count, chain +
    +
    06824edf55d0: a
    +
    parents:
    +
    10 +
    +
    06824edf55d0: a
    +
    parents:
    +
    11 def primes(): +
    +
    06824edf55d0: a
    +
    parents:
    +
    12 """Generate all primes.""" +
    +
    06824edf55d0: a
    +
    parents:
    +
    13 def sieve(ns): +
    +
    06824edf55d0: a
    +
    parents:
    +
    14 p = ns.next() +
    +
    06824edf55d0: a
    +
    parents:
    +
    15 # It is important to yield *here* in order to stop the +
    +
    06824edf55d0: a
    +
    parents:
    +
    16 # infinite recursion. +
    +
    06824edf55d0: a
    +
    parents:
    +
    17 yield p +
    +
    06824edf55d0: a
    +
    parents:
    +
    18 ns = ifilter(lambda n: n % p != 0, ns) +
    +
    06824edf55d0: a
    +
    parents:
    +
    19 for n in sieve(ns): +
    +
    06824edf55d0: a
    +
    parents:
    +
    20 yield n +
    +
    06824edf55d0: a
    +
    parents:
    +
    21 +
    +
    06824edf55d0: a
    +
    parents:
    +
    22 odds = ifilter(lambda i: i % 2 == 1, count()) +
    +
    06824edf55d0: a
    +
    parents:
    +
    23 return chain([2], sieve(dropwhile(lambda n: n < 3, odds))) +
    +
    06824edf55d0: a
    +
    parents:
    +
    24 +
    +
    06824edf55d0: a
    +
    parents:
    +
    25 if __name__ == "__main__": +
    +
    06824edf55d0: a
    +
    parents:
    +
    26 import sys +
    +
    06824edf55d0: a
    +
    parents:
    +
    27 try: +
    +
    06824edf55d0: a
    +
    parents:
    +
    28 n = int(sys.argv[1]) +
    +
    06824edf55d0: a
    +
    parents:
    +
    29 except (ValueError, IndexError): +
    +
    06824edf55d0: a
    +
    parents:
    +
    30 n = 10 +
    +
    06824edf55d0: a
    +
    parents:
    +
    31 p = primes() +
    +
    06824edf55d0: a
    +
    parents:
    +
    32 print "The first %d primes: %s" % (n, list(islice(p, n))) +
    +
    06824edf55d0: a
    +
    parents:
    +
    33