[PATCH 1 of 4] hgweb: add link to parents of annotated revision in annotate view

Denis Laxalde denis.laxalde at logilab.fr
Tue Jul 12 15:34:33 UTC 2016


# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1467106962 -7200
#      Tue Jun 28 11:42:42 2016 +0200
# Node ID fa7818afd0cba51a545b24a5bab3b45f04436674
# Parent  4b16a5bd99484cac96ade9af76e6deee1fc57b54
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 --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -864,6 +864,13 @@ 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(),
+            }
+
     def annotate(**map):
         if util.binary(fctx.data()):
             mt = (mimetypes.guess_type(fctx.path())[0]
@@ -882,6 +889,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>',
-          '')}
+          '<a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#l{targetline}">
+             {author|user}@{rev}
+           </a>')}
+      <div class="annotate-info">
+        <div>{node|short}: {desc|escape|firstline}</div>
+        <div>parents: {parents%annotateparent}</div>
+      </div>
     </td>
     <td><pre><a class="linenr" href="#{lineid}">{linenumber}</a></pre></td>
     <td><pre>{line|escape}</pre></td>
   </tr>'
+annotateparent = '
+  <a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{rev}</a>'
 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,17 +92,23 @@ 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>',
-          '')}
+          '<a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#l{targetline}">
+             {author|user}@{rev}
+           </a>')}
+      <div class="annotate-info">
+        <div>{node|short}: {desc|escape|firstline}</div>
+        <div>parents: {parents%annotateparent}</div>
+      </div>
     </td>
     <td class="lineno">
       <a href="#{lineid}">{linenumber}</a>
     </td>
     <td class="source">{line|escape}</td>
   </tr>'
+annotateparent = '
+  <a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{rev}</a>'
 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
@@ -79,13 +79,18 @@ annotateline = '
   <tr id="{lineid}"{ifeq(node, originalnode, ' class="thisrev"')}>
     <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>',
-          '')}
+          '<a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#l{targetline}">
+             {author|user}@{rev}
+           </a>')}
+      <div class="annotate-info">
+        <div>{node|short}: {desc|escape|firstline}</div>
+        <div>parents: {parents%annotateparent}</div>
+      </div>
     </td>
     <td class="source"><a href="#{lineid}">{linenumber}</a> {line|escape}</td>
   </tr>'
-
+annotateparent = '
+  <a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{rev}</a>'
 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
@@ -57,15 +57,21 @@ annotateline = '
   <tr class="parity{parity}{ifeq(node, originalnode, ' thisrev')}">
     <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>',
-          '')}
+          '<a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#l{targetline}">
+             {author|user}@{rev}
+           </a>')}
+      <div class="annotate-info">
+        <div>{node|short}: {desc|escape|firstline}</div>
+        <div>parents: {parents%annotateparent}</div>
+      </div>
     </td>
     <td>
       <a class="lineno" href="#{lineid}" id="{lineid}">{linenumber}</a>
     </td>
     <td><pre> {line|escape}</pre></td>
   </tr>'
+annotateparent = '
+  <a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{rev}</a>'
 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,17 @@ 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: 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 --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,17 @@ 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: 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 --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,17 @@ 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: 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 --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,17 @@ 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: 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 --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
@@ -1965,6 +1965,17 @@ 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: 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 --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
@@ -190,8 +190,9 @@ Set up the repo
    annotate foo @ 1:<a href="/rev/a7c1559b7bba?style=paper">a7c1559b7bba</a>
    <td class="author"><a href="/file/43c799df6e75/foo?style=paper">43c799df6e75</a> </td>
    <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"
+  <a href="/annotate/43c799df6e75/foo?style=paper#l1">
+  <a href="/annotate/a7c1559b7bba/foo?style=paper#l2">
+  <a href="/annotate/43c799df6e75/foo?style=paper">0</a></div>
 
   $ "$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>
@@ -378,8 +379,9 @@ Set up the repo
    annotate foo @ 1:<a href="/rev/a7c1559b7bba?style=coal">a7c1559b7bba</a>
    <td class="author"><a href="/file/43c799df6e75/foo?style=coal">43c799df6e75</a> </td>
    <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"
+  <a href="/annotate/43c799df6e75/foo?style=coal#l1">
+  <a href="/annotate/a7c1559b7bba/foo?style=coal#l2">
+  <a href="/annotate/43c799df6e75/foo?style=coal">0</a></div>
 
   $ "$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>
@@ -616,8 +618,9 @@ Set up the repo
    <td style="font-family:monospace"><a class="list" href="/rev/a7c1559b7bba?style=gitweb">a7c1559b7bba</a></td>
   <a class="list" href="/annotate/43c799df6e75/foo?style=gitweb">
   <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"
+  <a href="/annotate/43c799df6e75/foo?style=gitweb#l1">
+  <a href="/annotate/a7c1559b7bba/foo?style=gitweb#l2">
+  <a href="/annotate/43c799df6e75/foo?style=gitweb">0</a></div>
 
   $ "$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> |
@@ -832,8 +835,9 @@ Set up the repo
           <dd><a href="/rev/a7c1559b7bba?style=monoblue">a7c1559b7bba</a></dd>
   <a href="/annotate/43c799df6e75/foo?style=monoblue">
   <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"
+  <a href="/annotate/43c799df6e75/foo?style=monoblue#l1">
+  <a href="/annotate/a7c1559b7bba/foo?style=monoblue#l2">
+  <a href="/annotate/43c799df6e75/foo?style=monoblue">0</a></div>
 
   $ "$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>
@@ -1029,8 +1033,9 @@ Set up the repo
    <td><a href="/rev/a7c1559b7bba?style=spartan">a7c1559b7bba</a></td>
   <a href="/annotate/43c799df6e75/foo?style=spartan">
   <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"
+  <a href="/annotate/43c799df6e75/foo?style=spartan#l1">
+  <a href="/annotate/a7c1559b7bba/foo?style=spartan#l2">
+  <a href="/annotate/43c799df6e75/foo?style=spartan">0</a></div>
 
   $ "$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: 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 @@ 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: 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 --git a/tests/test-highlight.t b/tests/test-highlight.t
--- a/tests/test-highlight.t
+++ b/tests/test-highlight.t
@@ -290,200 +290,333 @@ hgweb fileannotate, html
     
   <tr id="l1" class="thisrev">
   <td class="annotate">
-  <a href="/annotate/06824edf55d0/primes.py#l1"
-  title="06824edf55d0: a">test at 0</a>
+  <a href="/annotate/06824edf55d0/primes.py#l1">
+  test at 0
+  </a>
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </td>
   <td class="source"><a href="#l1">     1</a> <span class="c">#!/usr/bin/env python</span></td>
   </tr>
   <tr id="l2" class="thisrev">
   <td class="annotate">
   
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </td>
   <td class="source"><a href="#l2">     2</a> </td>
   </tr>
   <tr id="l3" class="thisrev">
   <td class="annotate">
   
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </td>
   <td class="source"><a href="#l3">     3</a> <span class="sd">"""Fun with generators. Corresponding Haskell implementation:</span></td>
   </tr>
   <tr id="l4" class="thisrev">
   <td class="annotate">
   
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </td>
   <td class="source"><a href="#l4">     4</a> </td>
   </tr>
   <tr id="l5" class="thisrev">
   <td class="annotate">
   
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </td>
   <td class="source"><a href="#l5">     5</a> <span class="sd">primes = 2 : sieve [3, 5..]</span></td>
   </tr>
   <tr id="l6" class="thisrev">
   <td class="annotate">
   
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </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" class="thisrev">
   <td class="annotate">
   
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </td>
   <td class="source"><a href="#l7">     7</a> <span class="sd">"""</span></td>
   </tr>
   <tr id="l8" class="thisrev">
   <td class="annotate">
   
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </td>
   <td class="source"><a href="#l8">     8</a> </td>
   </tr>
   <tr id="l9" class="thisrev">
   <td class="annotate">
   
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </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" class="thisrev">
   <td class="annotate">
   
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </td>
   <td class="source"><a href="#l10">    10</a> </td>
   </tr>
   <tr id="l11" class="thisrev">
   <td class="annotate">
   
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </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" class="thisrev">
   <td class="annotate">
   
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </td>
   <td class="source"><a href="#l12">    12</a>     <span class="sd">"""Generate all primes."""</span></td>
   </tr>
   <tr id="l13" class="thisrev">
   <td class="annotate">
   
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </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" class="thisrev">
   <td class="annotate">
   
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </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" class="thisrev">
   <td class="annotate">
   
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </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" class="thisrev">
   <td class="annotate">
   
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </td>
   <td class="source"><a href="#l16">    16</a>         <span class="c"># infinite recursion.</span></td>
   </tr>
   <tr id="l17" class="thisrev">
   <td class="annotate">
   
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </td>
   <td class="source"><a href="#l17">    17</a>         <span class="kn">yield</span> <span class="n">p</span></td>
   </tr>
   <tr id="l18" class="thisrev">
   <td class="annotate">
   
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </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" class="thisrev">
   <td class="annotate">
   
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </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" class="thisrev">
   <td class="annotate">
   
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </td>
   <td class="source"><a href="#l20">    20</a>             <span class="kn">yield</span> <span class="n">n</span></td>
   </tr>
   <tr id="l21" class="thisrev">
   <td class="annotate">
   
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </td>
   <td class="source"><a href="#l21">    21</a> </td>
   </tr>
   <tr id="l22" class="thisrev">
   <td class="annotate">
   
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </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" class="thisrev">
   <td class="annotate">
   
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </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" class="thisrev">
   <td class="annotate">
   
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </td>
   <td class="source"><a href="#l24">    24</a> </td>
   </tr>
   <tr id="l25" class="thisrev">
   <td class="annotate">
   
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </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" class="thisrev">
   <td class="annotate">
   
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </td>
   <td class="source"><a href="#l26">    26</a>     <span class="kn">import</span> <span class="nn">sys</span></td>
   </tr>
   <tr id="l27" class="thisrev">
   <td class="annotate">
   
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </td>
   <td class="source"><a href="#l27">    27</a>     <span class="kn">try</span><span class="p">:</span></td>
   </tr>
   <tr id="l28" class="thisrev">
   <td class="annotate">
   
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </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" class="thisrev">
   <td class="annotate">
   
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </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" class="thisrev">
   <td class="annotate">
   
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </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" class="thisrev">
   <td class="annotate">
   
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </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" class="thisrev">
   <td class="annotate">
   
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </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" class="thisrev">
   <td class="annotate">
   
+  <div class="annotate-info">
+  <div>06824edf55d0: a</div>
+  <div>parents: </div>
+  </div>
   </td>
   <td class="source"><a href="#l33">    33</a> </td>
   </tr>


More information about the Mercurial-devel mailing list