##// END OF EJS Templates
py3: fix module imports in test-highlight.t...
Matt Harbison -
r40406:3b84ef90 default
parent child Browse files
Show More
@@ -1,1017 +1,1036 b''
1 #require pygments serve
1 #require pygments serve
2
2
3 $ cat <<EOF >> $HGRCPATH
3 $ cat <<EOF >> $HGRCPATH
4 > [extensions]
4 > [extensions]
5 > highlight =
5 > highlight =
6 > [web]
6 > [web]
7 > pygments_style = friendly
7 > pygments_style = friendly
8 > highlightfiles = **.py and size('<100KB')
8 > highlightfiles = **.py and size('<100KB')
9 > EOF
9 > EOF
10 $ hg init test
10 $ hg init test
11 $ cd test
11 $ cd test
12
12
13 $ filterhtml () {
13 $ filterhtml () {
14 > sed -e "s/class=\"k\"/class=\"kn\"/g" \
14 > sed -e "s/class=\"k\"/class=\"kn\"/g" \
15 > -e "s/class=\"mf\"/class=\"mi\"/g" \
15 > -e "s/class=\"mf\"/class=\"mi\"/g" \
16 > -e "s/class=\"vm\"/class=\"n\"/g" \
16 > -e "s/class=\"vm\"/class=\"n\"/g" \
17 > -e "s/class=\"\([cs]\)[h12]\"/class=\"\1\"/g"
17 > -e "s/class=\"\([cs]\)[h12]\"/class=\"\1\"/g"
18 > }
18 > }
19
19
20 create random Python file to exercise Pygments
20 create random Python file to exercise Pygments
21
21
22 $ cat <<EOF > primes.py
22 $ cat <<EOF > primes.py
23 > """Fun with generators. Corresponding Haskell implementation:
23 > """Fun with generators. Corresponding Haskell implementation:
24 >
24 >
25 > primes = 2 : sieve [3, 5..]
25 > primes = 2 : sieve [3, 5..]
26 > where sieve (p:ns) = p : sieve [n | n <- ns, mod n p /= 0]
26 > where sieve (p:ns) = p : sieve [n | n <- ns, mod n p /= 0]
27 > """
27 > """
28 >
28 >
29 > from itertools import dropwhile, ifilter, islice, count, chain
29 > import itertools
30 >
30 >
31 > def primes():
31 > def primes():
32 > """Generate all primes."""
32 > """Generate all primes."""
33 > def sieve(ns):
33 > def sieve(ns):
34 > p = ns.next()
34 > p = ns.next()
35 > # It is important to yield *here* in order to stop the
35 > # It is important to yield *here* in order to stop the
36 > # infinite recursion.
36 > # infinite recursion.
37 > yield p
37 > yield p
38 > ns = ifilter(lambda n: n % p != 0, ns)
38 > ns = itertools.ifilter(lambda n: n % p != 0, ns)
39 > for n in sieve(ns):
39 > for n in sieve(ns):
40 > yield n
40 > yield n
41 >
41 >
42 > odds = ifilter(lambda i: i % 2 == 1, count())
42 > odds = itertools.ifilter(lambda i: i % 2 == 1, itertools.count())
43 > return chain([2], sieve(dropwhile(lambda n: n < 3, odds)))
43 > dropwhile = itertools.dropwhile
44 > return itertools.chain([2], sieve(dropwhile(lambda n: n < 3, odds)))
44 >
45 >
45 > if __name__ == "__main__":
46 > if __name__ == "__main__":
46 > import sys
47 > import sys
47 > try:
48 > try:
48 > n = int(sys.argv[1])
49 > n = int(sys.argv[1])
49 > except (ValueError, IndexError):
50 > except (ValueError, IndexError):
50 > n = 10
51 > n = 10
51 > p = primes()
52 > p = primes()
52 > print("The first %d primes: %s" % (n, list(islice(p, n))))
53 > print("The first %d primes: %s" % (n, list(itertools.islice(p, n))))
53 > EOF
54 > EOF
54 $ echo >> primes.py # to test html markup with an empty line just before EOF
55 $ echo >> primes.py # to test html markup with an empty line just before EOF
55 $ hg ci -Ama
56 $ hg ci -Ama
56 adding primes.py
57 adding primes.py
57
58
58 hg serve
59 hg serve
59
60
60 $ hg serve -p $HGPORT -d -n test --pid-file=hg.pid -A access.log -E errors.log
61 $ hg serve -p $HGPORT -d -n test --pid-file=hg.pid -A access.log -E errors.log
61 $ cat hg.pid >> $DAEMON_PIDS
62 $ cat hg.pid >> $DAEMON_PIDS
62
63
63 hgweb filerevision, html
64 hgweb filerevision, html
64
65
65 $ (get-with-headers.py localhost:$HGPORT 'file/tip/primes.py') | filterhtml
66 $ (get-with-headers.py localhost:$HGPORT 'file/tip/primes.py') | filterhtml
66 200 Script output follows
67 200 Script output follows
67
68
68 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
69 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
69 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
70 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
70 <head>
71 <head>
71 <link rel="icon" href="/static/hgicon.png" type="image/png" />
72 <link rel="icon" href="/static/hgicon.png" type="image/png" />
72 <meta name="robots" content="index, nofollow" />
73 <meta name="robots" content="index, nofollow" />
73 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
74 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
74 <script type="text/javascript" src="/static/mercurial.js"></script>
75 <script type="text/javascript" src="/static/mercurial.js"></script>
75
76
76 <link rel="stylesheet" href="/highlightcss" type="text/css" />
77 <link rel="stylesheet" href="/highlightcss" type="text/css" />
77 <title>test: f4fca47b67e6 primes.py</title>
78 <title>test: 687f2d169546 primes.py</title>
78 </head>
79 </head>
79 <body>
80 <body>
80
81
81 <div class="container">
82 <div class="container">
82 <div class="menu">
83 <div class="menu">
83 <div class="logo">
84 <div class="logo">
84 <a href="https://mercurial-scm.org/">
85 <a href="https://mercurial-scm.org/">
85 <img src="/static/hglogo.png" alt="mercurial" /></a>
86 <img src="/static/hglogo.png" alt="mercurial" /></a>
86 </div>
87 </div>
87 <ul>
88 <ul>
88 <li><a href="/shortlog/tip">log</a></li>
89 <li><a href="/shortlog/tip">log</a></li>
89 <li><a href="/graph/tip">graph</a></li>
90 <li><a href="/graph/tip">graph</a></li>
90 <li><a href="/tags">tags</a></li>
91 <li><a href="/tags">tags</a></li>
91 <li><a href="/bookmarks">bookmarks</a></li>
92 <li><a href="/bookmarks">bookmarks</a></li>
92 <li><a href="/branches">branches</a></li>
93 <li><a href="/branches">branches</a></li>
93 </ul>
94 </ul>
94 <ul>
95 <ul>
95 <li><a href="/rev/tip">changeset</a></li>
96 <li><a href="/rev/tip">changeset</a></li>
96 <li><a href="/file/tip/">browse</a></li>
97 <li><a href="/file/tip/">browse</a></li>
97 </ul>
98 </ul>
98 <ul>
99 <ul>
99 <li class="active">file</li>
100 <li class="active">file</li>
100 <li><a href="/file/tip/primes.py">latest</a></li>
101 <li><a href="/file/tip/primes.py">latest</a></li>
101 <li><a href="/diff/tip/primes.py">diff</a></li>
102 <li><a href="/diff/tip/primes.py">diff</a></li>
102 <li><a href="/comparison/tip/primes.py">comparison</a></li>
103 <li><a href="/comparison/tip/primes.py">comparison</a></li>
103 <li><a href="/annotate/tip/primes.py">annotate</a></li>
104 <li><a href="/annotate/tip/primes.py">annotate</a></li>
104 <li><a href="/log/tip/primes.py">file log</a></li>
105 <li><a href="/log/tip/primes.py">file log</a></li>
105 <li><a href="/raw-file/tip/primes.py">raw</a></li>
106 <li><a href="/raw-file/tip/primes.py">raw</a></li>
106 </ul>
107 </ul>
107 <ul>
108 <ul>
108 <li><a href="/help">help</a></li>
109 <li><a href="/help">help</a></li>
109 </ul>
110 </ul>
110 </div>
111 </div>
111
112
112 <div class="main">
113 <div class="main">
113 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
114 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
114 <h3>
115 <h3>
115 view primes.py @ 0:<a href="/rev/f4fca47b67e6">f4fca47b67e6</a>
116 view primes.py @ 0:<a href="/rev/687f2d169546">687f2d169546</a>
116 <span class="phase">draft</span> <span class="branchhead">default</span> <span class="tag">tip</span>
117 <span class="phase">draft</span> <span class="branchhead">default</span> <span class="tag">tip</span>
117 </h3>
118 </h3>
118
119
119
120
120 <form class="search" action="/log">
121 <form class="search" action="/log">
121
122
122 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
123 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
123 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
124 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
124 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
125 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
125 </form>
126 </form>
126
127
127 <div class="description">a</div>
128 <div class="description">a</div>
128
129
129 <table id="changesetEntry">
130 <table id="changesetEntry">
130 <tr>
131 <tr>
131 <th class="author">author</th>
132 <th class="author">author</th>
132 <td class="author">&#116;&#101;&#115;&#116;</td>
133 <td class="author">&#116;&#101;&#115;&#116;</td>
133 </tr>
134 </tr>
134 <tr>
135 <tr>
135 <th class="date">date</th>
136 <th class="date">date</th>
136 <td class="date age">Thu, 01 Jan 1970 00:00:00 +0000</td>
137 <td class="date age">Thu, 01 Jan 1970 00:00:00 +0000</td>
137 </tr>
138 </tr>
138 <tr>
139 <tr>
139 <th class="author">parents</th>
140 <th class="author">parents</th>
140 <td class="author"></td>
141 <td class="author"></td>
141 </tr>
142 </tr>
142 <tr>
143 <tr>
143 <th class="author">children</th>
144 <th class="author">children</th>
144 <td class="author"></td>
145 <td class="author"></td>
145 </tr>
146 </tr>
146 </table>
147 </table>
147
148
148 <div class="overflow">
149 <div class="overflow">
149 <div class="sourcefirst linewraptoggle">line wrap: <a class="linewraplink" href="#">on</a></div>
150 <div class="sourcefirst linewraptoggle">line wrap: <a class="linewraplink" href="#">on</a></div>
150 <div class="sourcefirst"> line source</div>
151 <div class="sourcefirst"> line source</div>
151 <pre class="sourcelines stripes4 wrap bottomline"
152 <pre class="sourcelines stripes4 wrap bottomline"
152 data-logurl="/log/tip/primes.py"
153 data-logurl="/log/tip/primes.py"
153 data-selectabletag="SPAN"
154 data-selectabletag="SPAN"
154 data-ishead="1">
155 data-ishead="1">
155
156
156 <span id="l1"><span class="sd">&quot;&quot;&quot;Fun with generators. Corresponding Haskell implementation:</span></span><a href="#l1"></a>
157 <span id="l1"><span class="sd">&quot;&quot;&quot;Fun with generators. Corresponding Haskell implementation:</span></span><a href="#l1"></a>
157 <span id="l2"></span><a href="#l2"></a>
158 <span id="l2"></span><a href="#l2"></a>
158 <span id="l3"><span class="sd">primes = 2 : sieve [3, 5..]</span></span><a href="#l3"></a>
159 <span id="l3"><span class="sd">primes = 2 : sieve [3, 5..]</span></span><a href="#l3"></a>
159 <span id="l4"><span class="sd"> where sieve (p:ns) = p : sieve [n | n &lt;- ns, mod n p /= 0]</span></span><a href="#l4"></a>
160 <span id="l4"><span class="sd"> where sieve (p:ns) = p : sieve [n | n &lt;- ns, mod n p /= 0]</span></span><a href="#l4"></a>
160 <span id="l5"><span class="sd">&quot;&quot;&quot;</span></span><a href="#l5"></a>
161 <span id="l5"><span class="sd">&quot;&quot;&quot;</span></span><a href="#l5"></a>
161 <span id="l6"></span><a href="#l6"></a>
162 <span id="l6"></span><a href="#l6"></a>
162 <span id="l7"><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></span><a href="#l7"></a>
163 <span id="l7"><span class="kn">import</span> <span class="nn">itertools</span></span><a href="#l7"></a>
163 <span id="l8"></span><a href="#l8"></a>
164 <span id="l8"></span><a href="#l8"></a>
164 <span id="l9"><span class="kn">def</span> <span class="nf">primes</span><span class="p">():</span></span><a href="#l9"></a>
165 <span id="l9"><span class="kn">def</span> <span class="nf">primes</span><span class="p">():</span></span><a href="#l9"></a>
165 <span id="l10"> <span class="sd">&quot;&quot;&quot;Generate all primes.&quot;&quot;&quot;</span></span><a href="#l10"></a>
166 <span id="l10"> <span class="sd">&quot;&quot;&quot;Generate all primes.&quot;&quot;&quot;</span></span><a href="#l10"></a>
166 <span id="l11"> <span class="kn">def</span> <span class="nf">sieve</span><span class="p">(</span><span class="n">ns</span><span class="p">):</span></span><a href="#l11"></a>
167 <span id="l11"> <span class="kn">def</span> <span class="nf">sieve</span><span class="p">(</span><span class="n">ns</span><span class="p">):</span></span><a href="#l11"></a>
167 <span id="l12"> <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></span><a href="#l12"></a>
168 <span id="l12"> <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></span><a href="#l12"></a>
168 <span id="l13"> <span class="c"># It is important to yield *here* in order to stop the</span></span><a href="#l13"></a>
169 <span id="l13"> <span class="c"># It is important to yield *here* in order to stop the</span></span><a href="#l13"></a>
169 <span id="l14"> <span class="c"># infinite recursion.</span></span><a href="#l14"></a>
170 <span id="l14"> <span class="c"># infinite recursion.</span></span><a href="#l14"></a>
170 <span id="l15"> <span class="kn">yield</span> <span class="n">p</span></span><a href="#l15"></a>
171 <span id="l15"> <span class="kn">yield</span> <span class="n">p</span></span><a href="#l15"></a>
171 <span id="l16"> <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></span><a href="#l16"></a>
172 <span id="l16"> <span class="n">ns</span> <span class="o">=</span> <span class="n">itertools</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></span><a href="#l16"></a>
172 <span id="l17"> <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></span><a href="#l17"></a>
173 <span id="l17"> <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></span><a href="#l17"></a>
173 <span id="l18"> <span class="kn">yield</span> <span class="n">n</span></span><a href="#l18"></a>
174 <span id="l18"> <span class="kn">yield</span> <span class="n">n</span></span><a href="#l18"></a>
174 <span id="l19"></span><a href="#l19"></a>
175 <span id="l19"></span><a href="#l19"></a>
175 <span id="l20"> <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></span><a href="#l20"></a>
176 <span id="l20"> <span class="n">odds</span> <span class="o">=</span> <span class="n">itertools</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">itertools</span><span class="o">.</span><span class="n">count</span><span class="p">())</span></span><a href="#l20"></a>
176 <span id="l21"> <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">&lt;</span> <span class="mi">3</span><span class="p">,</span> <span class="n">odds</span><span class="p">)))</span></span><a href="#l21"></a>
177 <span id="l21"> <span class="n">dropwhile</span> <span class="o">=</span> <span class="n">itertools</span><span class="o">.</span><span class="n">dropwhile</span></span><a href="#l21"></a>
177 <span id="l22"></span><a href="#l22"></a>
178 <span id="l22"> <span class="kn">return</span> <span class="n">itertools</span><span class="o">.</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">&lt;</span> <span class="mi">3</span><span class="p">,</span> <span class="n">odds</span><span class="p">)))</span></span><a href="#l22"></a>
178 <span id="l23"><span class="kn">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">&quot;__main__&quot;</span><span class="p">:</span></span><a href="#l23"></a>
179 <span id="l23"></span><a href="#l23"></a>
179 <span id="l24"> <span class="kn">import</span> <span class="nn">sys</span></span><a href="#l24"></a>
180 <span id="l24"><span class="kn">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">&quot;__main__&quot;</span><span class="p">:</span></span><a href="#l24"></a>
180 <span id="l25"> <span class="kn">try</span><span class="p">:</span></span><a href="#l25"></a>
181 <span id="l25"> <span class="kn">import</span> <span class="nn">sys</span></span><a href="#l25"></a>
181 <span id="l26"> <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></span><a href="#l26"></a>
182 <span id="l26"> <span class="kn">try</span><span class="p">:</span></span><a href="#l26"></a>
182 <span id="l27"> <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></span><a href="#l27"></a>
183 <span id="l27"> <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></span><a href="#l27"></a>
183 <span id="l28"> <span class="n">n</span> <span class="o">=</span> <span class="mi">10</span></span><a href="#l28"></a>
184 <span id="l28"> <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></span><a href="#l28"></a>
184 <span id="l29"> <span class="n">p</span> <span class="o">=</span> <span class="n">primes</span><span class="p">()</span></span><a href="#l29"></a>
185 <span id="l29"> <span class="n">n</span> <span class="o">=</span> <span class="mi">10</span></span><a href="#l29"></a>
185 <span id="l30"> <span class="kn">print</span><span class="p">(</span><span class="s">&quot;The first </span><span class="si">%d</span><span class="s"> primes: </span><span class="si">%s</span><span class="s">&quot;</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></span><a href="#l30"></a>
186 <span id="l30"> <span class="n">p</span> <span class="o">=</span> <span class="n">primes</span><span class="p">()</span></span><a href="#l30"></a>
186 <span id="l31"></span><a href="#l31"></a>
187 <span id="l31"> <span class="kn">print</span><span class="p">(</span><span class="s">&quot;The first </span><span class="si">%d</span><span class="s"> primes: </span><span class="si">%s</span><span class="s">&quot;</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">itertools</span><span class="o">.</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></span><a href="#l31"></a>
188 <span id="l32"></span><a href="#l32"></a>
187 </pre>
189 </pre>
188 </div>
190 </div>
189
191
190 <script type="text/javascript" src="/static/followlines.js"></script>
192 <script type="text/javascript" src="/static/followlines.js"></script>
191
193
192 </div>
194 </div>
193 </div>
195 </div>
194
196
195
197
196
198
197 </body>
199 </body>
198 </html>
200 </html>
199
201
200
202
201 hgweb fileannotate, html
203 hgweb fileannotate, html
202
204
203 $ (get-with-headers.py localhost:$HGPORT 'annotate/tip/primes.py') | filterhtml
205 $ (get-with-headers.py localhost:$HGPORT 'annotate/tip/primes.py') | filterhtml
204 200 Script output follows
206 200 Script output follows
205
207
206 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
208 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
207 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
209 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
208 <head>
210 <head>
209 <link rel="icon" href="/static/hgicon.png" type="image/png" />
211 <link rel="icon" href="/static/hgicon.png" type="image/png" />
210 <meta name="robots" content="index, nofollow" />
212 <meta name="robots" content="index, nofollow" />
211 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
213 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
212 <script type="text/javascript" src="/static/mercurial.js"></script>
214 <script type="text/javascript" src="/static/mercurial.js"></script>
213
215
214 <link rel="stylesheet" href="/highlightcss" type="text/css" />
216 <link rel="stylesheet" href="/highlightcss" type="text/css" />
215 <title>test: primes.py annotate</title>
217 <title>test: primes.py annotate</title>
216 </head>
218 </head>
217 <body>
219 <body>
218
220
219 <div class="container">
221 <div class="container">
220 <div class="menu">
222 <div class="menu">
221 <div class="logo">
223 <div class="logo">
222 <a href="https://mercurial-scm.org/">
224 <a href="https://mercurial-scm.org/">
223 <img src="/static/hglogo.png" alt="mercurial" /></a>
225 <img src="/static/hglogo.png" alt="mercurial" /></a>
224 </div>
226 </div>
225 <ul>
227 <ul>
226 <li><a href="/shortlog/tip">log</a></li>
228 <li><a href="/shortlog/tip">log</a></li>
227 <li><a href="/graph/tip">graph</a></li>
229 <li><a href="/graph/tip">graph</a></li>
228 <li><a href="/tags">tags</a></li>
230 <li><a href="/tags">tags</a></li>
229 <li><a href="/bookmarks">bookmarks</a></li>
231 <li><a href="/bookmarks">bookmarks</a></li>
230 <li><a href="/branches">branches</a></li>
232 <li><a href="/branches">branches</a></li>
231 </ul>
233 </ul>
232
234
233 <ul>
235 <ul>
234 <li><a href="/rev/tip">changeset</a></li>
236 <li><a href="/rev/tip">changeset</a></li>
235 <li><a href="/file/tip/">browse</a></li>
237 <li><a href="/file/tip/">browse</a></li>
236 </ul>
238 </ul>
237 <ul>
239 <ul>
238 <li><a href="/file/tip/primes.py">file</a></li>
240 <li><a href="/file/tip/primes.py">file</a></li>
239 <li><a href="/file/tip/primes.py">latest</a></li>
241 <li><a href="/file/tip/primes.py">latest</a></li>
240 <li><a href="/diff/tip/primes.py">diff</a></li>
242 <li><a href="/diff/tip/primes.py">diff</a></li>
241 <li><a href="/comparison/tip/primes.py">comparison</a></li>
243 <li><a href="/comparison/tip/primes.py">comparison</a></li>
242 <li class="active">annotate</li>
244 <li class="active">annotate</li>
243 <li><a href="/log/tip/primes.py">file log</a></li>
245 <li><a href="/log/tip/primes.py">file log</a></li>
244 <li><a href="/raw-file/tip/primes.py">raw</a></li>
246 <li><a href="/raw-file/tip/primes.py">raw</a></li>
245 </ul>
247 </ul>
246 <ul>
248 <ul>
247 <li><a href="/help">help</a></li>
249 <li><a href="/help">help</a></li>
248 </ul>
250 </ul>
249 </div>
251 </div>
250
252
251 <div class="main">
253 <div class="main">
252 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
254 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
253 <h3>
255 <h3>
254 annotate primes.py @ 0:<a href="/rev/f4fca47b67e6">f4fca47b67e6</a>
256 annotate primes.py @ 0:<a href="/rev/687f2d169546">687f2d169546</a>
255 <span class="phase">draft</span> <span class="branchhead">default</span> <span class="tag">tip</span>
257 <span class="phase">draft</span> <span class="branchhead">default</span> <span class="tag">tip</span>
256 </h3>
258 </h3>
257
259
258
260
259 <form class="search" action="/log">
261 <form class="search" action="/log">
260
262
261 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
263 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
262 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
264 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
263 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
265 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
264 </form>
266 </form>
265
267
266 <div class="description">a</div>
268 <div class="description">a</div>
267
269
268 <table id="changesetEntry">
270 <table id="changesetEntry">
269 <tr>
271 <tr>
270 <th class="author">author</th>
272 <th class="author">author</th>
271 <td class="author">&#116;&#101;&#115;&#116;</td>
273 <td class="author">&#116;&#101;&#115;&#116;</td>
272 </tr>
274 </tr>
273 <tr>
275 <tr>
274 <th class="date">date</th>
276 <th class="date">date</th>
275 <td class="date age">Thu, 01 Jan 1970 00:00:00 +0000</td>
277 <td class="date age">Thu, 01 Jan 1970 00:00:00 +0000</td>
276 </tr>
278 </tr>
277 <tr>
279 <tr>
278 <th class="author">parents</th>
280 <th class="author">parents</th>
279 <td class="author"></td>
281 <td class="author"></td>
280 </tr>
282 </tr>
281 <tr>
283 <tr>
282 <th class="author">children</th>
284 <th class="author">children</th>
283 <td class="author"></td>
285 <td class="author"></td>
284 </tr>
286 </tr>
285 </table>
287 </table>
286
288
287
289
288 <form id="diffopts-form"
290 <form id="diffopts-form"
289 data-ignorews="0"
291 data-ignorews="0"
290 data-ignorewsamount="0"
292 data-ignorewsamount="0"
291 data-ignorewseol="0"
293 data-ignorewseol="0"
292 data-ignoreblanklines="0">
294 data-ignoreblanklines="0">
293 <span>Ignore whitespace changes - </span>
295 <span>Ignore whitespace changes - </span>
294 <span>Everywhere:</span>
296 <span>Everywhere:</span>
295 <input id="ignorews-checkbox" type="checkbox" />
297 <input id="ignorews-checkbox" type="checkbox" />
296 <span>Within whitespace:</span>
298 <span>Within whitespace:</span>
297 <input id="ignorewsamount-checkbox" type="checkbox" />
299 <input id="ignorewsamount-checkbox" type="checkbox" />
298 <span>At end of lines:</span>
300 <span>At end of lines:</span>
299 <input id="ignorewseol-checkbox" type="checkbox" />
301 <input id="ignorewseol-checkbox" type="checkbox" />
300 </form>
302 </form>
301
303
302 <script type="text/javascript">
304 <script type="text/javascript">
303 renderDiffOptsForm();
305 renderDiffOptsForm();
304 </script>
306 </script>
305
307
306 <div class="overflow">
308 <div class="overflow">
307 <table class="bigtable">
309 <table class="bigtable">
308 <thead>
310 <thead>
309 <tr>
311 <tr>
310 <th class="annotate">rev</th>
312 <th class="annotate">rev</th>
311 <th class="line">&nbsp;&nbsp;line source</th>
313 <th class="line">&nbsp;&nbsp;line source</th>
312 </tr>
314 </tr>
313 </thead>
315 </thead>
314 <tbody class="stripes2 sourcelines"
316 <tbody class="stripes2 sourcelines"
315 data-logurl="/log/tip/primes.py"
317 data-logurl="/log/tip/primes.py"
316 data-selectabletag="TR"
318 data-selectabletag="TR"
317 data-ishead="1">
319 data-ishead="1">
318
320
319 <tr id="l1" class="thisrev">
321 <tr id="l1" class="thisrev">
320 <td class="annotate parity0">
322 <td class="annotate parity0">
321 <a href="/annotate/f4fca47b67e6/primes.py#l1">
323 <a href="/annotate/687f2d169546/primes.py#l1">
322 0
324 0
323 </a>
325 </a>
324 <div class="annotate-info">
326 <div class="annotate-info">
325 <div>
327 <div>
326 <a href="/annotate/f4fca47b67e6/primes.py#l1">
328 <a href="/annotate/687f2d169546/primes.py#l1">
327 f4fca47b67e6</a>
329 687f2d169546</a>
328 a
330 a
329 </div>
331 </div>
330 <div><em>&#116;&#101;&#115;&#116;</em></div>
332 <div><em>&#116;&#101;&#115;&#116;</em></div>
331 <div>parents: </div>
333 <div>parents: </div>
332 <a href="/diff/f4fca47b67e6/primes.py">diff</a>
334 <a href="/diff/687f2d169546/primes.py">diff</a>
333 <a href="/rev/f4fca47b67e6">changeset</a>
335 <a href="/rev/687f2d169546">changeset</a>
334 </div>
336 </div>
335 </td>
337 </td>
336 <td class="source followlines-btn-parent"><a href="#l1"> 1</a> <span class="sd">&quot;&quot;&quot;Fun with generators. Corresponding Haskell implementation:</span></td>
338 <td class="source followlines-btn-parent"><a href="#l1"> 1</a> <span class="sd">&quot;&quot;&quot;Fun with generators. Corresponding Haskell implementation:</span></td>
337 </tr>
339 </tr>
338 <tr id="l2" class="thisrev">
340 <tr id="l2" class="thisrev">
339 <td class="annotate parity0">
341 <td class="annotate parity0">
340
342
341 <div class="annotate-info">
343 <div class="annotate-info">
342 <div>
344 <div>
343 <a href="/annotate/f4fca47b67e6/primes.py#l2">
345 <a href="/annotate/687f2d169546/primes.py#l2">
344 f4fca47b67e6</a>
346 687f2d169546</a>
345 a
347 a
346 </div>
348 </div>
347 <div><em>&#116;&#101;&#115;&#116;</em></div>
349 <div><em>&#116;&#101;&#115;&#116;</em></div>
348 <div>parents: </div>
350 <div>parents: </div>
349 <a href="/diff/f4fca47b67e6/primes.py">diff</a>
351 <a href="/diff/687f2d169546/primes.py">diff</a>
350 <a href="/rev/f4fca47b67e6">changeset</a>
352 <a href="/rev/687f2d169546">changeset</a>
351 </div>
353 </div>
352 </td>
354 </td>
353 <td class="source followlines-btn-parent"><a href="#l2"> 2</a> </td>
355 <td class="source followlines-btn-parent"><a href="#l2"> 2</a> </td>
354 </tr>
356 </tr>
355 <tr id="l3" class="thisrev">
357 <tr id="l3" class="thisrev">
356 <td class="annotate parity0">
358 <td class="annotate parity0">
357
359
358 <div class="annotate-info">
360 <div class="annotate-info">
359 <div>
361 <div>
360 <a href="/annotate/f4fca47b67e6/primes.py#l3">
362 <a href="/annotate/687f2d169546/primes.py#l3">
361 f4fca47b67e6</a>
363 687f2d169546</a>
362 a
364 a
363 </div>
365 </div>
364 <div><em>&#116;&#101;&#115;&#116;</em></div>
366 <div><em>&#116;&#101;&#115;&#116;</em></div>
365 <div>parents: </div>
367 <div>parents: </div>
366 <a href="/diff/f4fca47b67e6/primes.py">diff</a>
368 <a href="/diff/687f2d169546/primes.py">diff</a>
367 <a href="/rev/f4fca47b67e6">changeset</a>
369 <a href="/rev/687f2d169546">changeset</a>
368 </div>
370 </div>
369 </td>
371 </td>
370 <td class="source followlines-btn-parent"><a href="#l3"> 3</a> <span class="sd">primes = 2 : sieve [3, 5..]</span></td>
372 <td class="source followlines-btn-parent"><a href="#l3"> 3</a> <span class="sd">primes = 2 : sieve [3, 5..]</span></td>
371 </tr>
373 </tr>
372 <tr id="l4" class="thisrev">
374 <tr id="l4" class="thisrev">
373 <td class="annotate parity0">
375 <td class="annotate parity0">
374
376
375 <div class="annotate-info">
377 <div class="annotate-info">
376 <div>
378 <div>
377 <a href="/annotate/f4fca47b67e6/primes.py#l4">
379 <a href="/annotate/687f2d169546/primes.py#l4">
378 f4fca47b67e6</a>
380 687f2d169546</a>
379 a
381 a
380 </div>
382 </div>
381 <div><em>&#116;&#101;&#115;&#116;</em></div>
383 <div><em>&#116;&#101;&#115;&#116;</em></div>
382 <div>parents: </div>
384 <div>parents: </div>
383 <a href="/diff/f4fca47b67e6/primes.py">diff</a>
385 <a href="/diff/687f2d169546/primes.py">diff</a>
384 <a href="/rev/f4fca47b67e6">changeset</a>
386 <a href="/rev/687f2d169546">changeset</a>
385 </div>
387 </div>
386 </td>
388 </td>
387 <td class="source followlines-btn-parent"><a href="#l4"> 4</a> <span class="sd"> where sieve (p:ns) = p : sieve [n | n &lt;- ns, mod n p /= 0]</span></td>
389 <td class="source followlines-btn-parent"><a href="#l4"> 4</a> <span class="sd"> where sieve (p:ns) = p : sieve [n | n &lt;- ns, mod n p /= 0]</span></td>
388 </tr>
390 </tr>
389 <tr id="l5" class="thisrev">
391 <tr id="l5" class="thisrev">
390 <td class="annotate parity0">
392 <td class="annotate parity0">
391
393
392 <div class="annotate-info">
394 <div class="annotate-info">
393 <div>
395 <div>
394 <a href="/annotate/f4fca47b67e6/primes.py#l5">
396 <a href="/annotate/687f2d169546/primes.py#l5">
395 f4fca47b67e6</a>
397 687f2d169546</a>
396 a
398 a
397 </div>
399 </div>
398 <div><em>&#116;&#101;&#115;&#116;</em></div>
400 <div><em>&#116;&#101;&#115;&#116;</em></div>
399 <div>parents: </div>
401 <div>parents: </div>
400 <a href="/diff/f4fca47b67e6/primes.py">diff</a>
402 <a href="/diff/687f2d169546/primes.py">diff</a>
401 <a href="/rev/f4fca47b67e6">changeset</a>
403 <a href="/rev/687f2d169546">changeset</a>
402 </div>
404 </div>
403 </td>
405 </td>
404 <td class="source followlines-btn-parent"><a href="#l5"> 5</a> <span class="sd">&quot;&quot;&quot;</span></td>
406 <td class="source followlines-btn-parent"><a href="#l5"> 5</a> <span class="sd">&quot;&quot;&quot;</span></td>
405 </tr>
407 </tr>
406 <tr id="l6" class="thisrev">
408 <tr id="l6" class="thisrev">
407 <td class="annotate parity0">
409 <td class="annotate parity0">
408
410
409 <div class="annotate-info">
411 <div class="annotate-info">
410 <div>
412 <div>
411 <a href="/annotate/f4fca47b67e6/primes.py#l6">
413 <a href="/annotate/687f2d169546/primes.py#l6">
412 f4fca47b67e6</a>
414 687f2d169546</a>
413 a
415 a
414 </div>
416 </div>
415 <div><em>&#116;&#101;&#115;&#116;</em></div>
417 <div><em>&#116;&#101;&#115;&#116;</em></div>
416 <div>parents: </div>
418 <div>parents: </div>
417 <a href="/diff/f4fca47b67e6/primes.py">diff</a>
419 <a href="/diff/687f2d169546/primes.py">diff</a>
418 <a href="/rev/f4fca47b67e6">changeset</a>
420 <a href="/rev/687f2d169546">changeset</a>
419 </div>
421 </div>
420 </td>
422 </td>
421 <td class="source followlines-btn-parent"><a href="#l6"> 6</a> </td>
423 <td class="source followlines-btn-parent"><a href="#l6"> 6</a> </td>
422 </tr>
424 </tr>
423 <tr id="l7" class="thisrev">
425 <tr id="l7" class="thisrev">
424 <td class="annotate parity0">
426 <td class="annotate parity0">
425
427
426 <div class="annotate-info">
428 <div class="annotate-info">
427 <div>
429 <div>
428 <a href="/annotate/f4fca47b67e6/primes.py#l7">
430 <a href="/annotate/687f2d169546/primes.py#l7">
429 f4fca47b67e6</a>
431 687f2d169546</a>
430 a
432 a
431 </div>
433 </div>
432 <div><em>&#116;&#101;&#115;&#116;</em></div>
434 <div><em>&#116;&#101;&#115;&#116;</em></div>
433 <div>parents: </div>
435 <div>parents: </div>
434 <a href="/diff/f4fca47b67e6/primes.py">diff</a>
436 <a href="/diff/687f2d169546/primes.py">diff</a>
435 <a href="/rev/f4fca47b67e6">changeset</a>
437 <a href="/rev/687f2d169546">changeset</a>
436 </div>
438 </div>
437 </td>
439 </td>
438 <td class="source followlines-btn-parent"><a href="#l7"> 7</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>
440 <td class="source followlines-btn-parent"><a href="#l7"> 7</a> <span class="kn">import</span> <span class="nn">itertools</span></td>
439 </tr>
441 </tr>
440 <tr id="l8" class="thisrev">
442 <tr id="l8" class="thisrev">
441 <td class="annotate parity0">
443 <td class="annotate parity0">
442
444
443 <div class="annotate-info">
445 <div class="annotate-info">
444 <div>
446 <div>
445 <a href="/annotate/f4fca47b67e6/primes.py#l8">
447 <a href="/annotate/687f2d169546/primes.py#l8">
446 f4fca47b67e6</a>
448 687f2d169546</a>
447 a
449 a
448 </div>
450 </div>
449 <div><em>&#116;&#101;&#115;&#116;</em></div>
451 <div><em>&#116;&#101;&#115;&#116;</em></div>
450 <div>parents: </div>
452 <div>parents: </div>
451 <a href="/diff/f4fca47b67e6/primes.py">diff</a>
453 <a href="/diff/687f2d169546/primes.py">diff</a>
452 <a href="/rev/f4fca47b67e6">changeset</a>
454 <a href="/rev/687f2d169546">changeset</a>
453 </div>
455 </div>
454 </td>
456 </td>
455 <td class="source followlines-btn-parent"><a href="#l8"> 8</a> </td>
457 <td class="source followlines-btn-parent"><a href="#l8"> 8</a> </td>
456 </tr>
458 </tr>
457 <tr id="l9" class="thisrev">
459 <tr id="l9" class="thisrev">
458 <td class="annotate parity0">
460 <td class="annotate parity0">
459
461
460 <div class="annotate-info">
462 <div class="annotate-info">
461 <div>
463 <div>
462 <a href="/annotate/f4fca47b67e6/primes.py#l9">
464 <a href="/annotate/687f2d169546/primes.py#l9">
463 f4fca47b67e6</a>
465 687f2d169546</a>
464 a
466 a
465 </div>
467 </div>
466 <div><em>&#116;&#101;&#115;&#116;</em></div>
468 <div><em>&#116;&#101;&#115;&#116;</em></div>
467 <div>parents: </div>
469 <div>parents: </div>
468 <a href="/diff/f4fca47b67e6/primes.py">diff</a>
470 <a href="/diff/687f2d169546/primes.py">diff</a>
469 <a href="/rev/f4fca47b67e6">changeset</a>
471 <a href="/rev/687f2d169546">changeset</a>
470 </div>
472 </div>
471 </td>
473 </td>
472 <td class="source followlines-btn-parent"><a href="#l9"> 9</a> <span class="kn">def</span> <span class="nf">primes</span><span class="p">():</span></td>
474 <td class="source followlines-btn-parent"><a href="#l9"> 9</a> <span class="kn">def</span> <span class="nf">primes</span><span class="p">():</span></td>
473 </tr>
475 </tr>
474 <tr id="l10" class="thisrev">
476 <tr id="l10" class="thisrev">
475 <td class="annotate parity0">
477 <td class="annotate parity0">
476
478
477 <div class="annotate-info">
479 <div class="annotate-info">
478 <div>
480 <div>
479 <a href="/annotate/f4fca47b67e6/primes.py#l10">
481 <a href="/annotate/687f2d169546/primes.py#l10">
480 f4fca47b67e6</a>
482 687f2d169546</a>
481 a
483 a
482 </div>
484 </div>
483 <div><em>&#116;&#101;&#115;&#116;</em></div>
485 <div><em>&#116;&#101;&#115;&#116;</em></div>
484 <div>parents: </div>
486 <div>parents: </div>
485 <a href="/diff/f4fca47b67e6/primes.py">diff</a>
487 <a href="/diff/687f2d169546/primes.py">diff</a>
486 <a href="/rev/f4fca47b67e6">changeset</a>
488 <a href="/rev/687f2d169546">changeset</a>
487 </div>
489 </div>
488 </td>
490 </td>
489 <td class="source followlines-btn-parent"><a href="#l10"> 10</a> <span class="sd">&quot;&quot;&quot;Generate all primes.&quot;&quot;&quot;</span></td>
491 <td class="source followlines-btn-parent"><a href="#l10"> 10</a> <span class="sd">&quot;&quot;&quot;Generate all primes.&quot;&quot;&quot;</span></td>
490 </tr>
492 </tr>
491 <tr id="l11" class="thisrev">
493 <tr id="l11" class="thisrev">
492 <td class="annotate parity0">
494 <td class="annotate parity0">
493
495
494 <div class="annotate-info">
496 <div class="annotate-info">
495 <div>
497 <div>
496 <a href="/annotate/f4fca47b67e6/primes.py#l11">
498 <a href="/annotate/687f2d169546/primes.py#l11">
497 f4fca47b67e6</a>
499 687f2d169546</a>
498 a
500 a
499 </div>
501 </div>
500 <div><em>&#116;&#101;&#115;&#116;</em></div>
502 <div><em>&#116;&#101;&#115;&#116;</em></div>
501 <div>parents: </div>
503 <div>parents: </div>
502 <a href="/diff/f4fca47b67e6/primes.py">diff</a>
504 <a href="/diff/687f2d169546/primes.py">diff</a>
503 <a href="/rev/f4fca47b67e6">changeset</a>
505 <a href="/rev/687f2d169546">changeset</a>
504 </div>
506 </div>
505 </td>
507 </td>
506 <td class="source followlines-btn-parent"><a href="#l11"> 11</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>
508 <td class="source followlines-btn-parent"><a href="#l11"> 11</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>
507 </tr>
509 </tr>
508 <tr id="l12" class="thisrev">
510 <tr id="l12" class="thisrev">
509 <td class="annotate parity0">
511 <td class="annotate parity0">
510
512
511 <div class="annotate-info">
513 <div class="annotate-info">
512 <div>
514 <div>
513 <a href="/annotate/f4fca47b67e6/primes.py#l12">
515 <a href="/annotate/687f2d169546/primes.py#l12">
514 f4fca47b67e6</a>
516 687f2d169546</a>
515 a
517 a
516 </div>
518 </div>
517 <div><em>&#116;&#101;&#115;&#116;</em></div>
519 <div><em>&#116;&#101;&#115;&#116;</em></div>
518 <div>parents: </div>
520 <div>parents: </div>
519 <a href="/diff/f4fca47b67e6/primes.py">diff</a>
521 <a href="/diff/687f2d169546/primes.py">diff</a>
520 <a href="/rev/f4fca47b67e6">changeset</a>
522 <a href="/rev/687f2d169546">changeset</a>
521 </div>
523 </div>
522 </td>
524 </td>
523 <td class="source followlines-btn-parent"><a href="#l12"> 12</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>
525 <td class="source followlines-btn-parent"><a href="#l12"> 12</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>
524 </tr>
526 </tr>
525 <tr id="l13" class="thisrev">
527 <tr id="l13" class="thisrev">
526 <td class="annotate parity0">
528 <td class="annotate parity0">
527
529
528 <div class="annotate-info">
530 <div class="annotate-info">
529 <div>
531 <div>
530 <a href="/annotate/f4fca47b67e6/primes.py#l13">
532 <a href="/annotate/687f2d169546/primes.py#l13">
531 f4fca47b67e6</a>
533 687f2d169546</a>
532 a
534 a
533 </div>
535 </div>
534 <div><em>&#116;&#101;&#115;&#116;</em></div>
536 <div><em>&#116;&#101;&#115;&#116;</em></div>
535 <div>parents: </div>
537 <div>parents: </div>
536 <a href="/diff/f4fca47b67e6/primes.py">diff</a>
538 <a href="/diff/687f2d169546/primes.py">diff</a>
537 <a href="/rev/f4fca47b67e6">changeset</a>
539 <a href="/rev/687f2d169546">changeset</a>
538 </div>
540 </div>
539 </td>
541 </td>
540 <td class="source followlines-btn-parent"><a href="#l13"> 13</a> <span class="c"># It is important to yield *here* in order to stop the</span></td>
542 <td class="source followlines-btn-parent"><a href="#l13"> 13</a> <span class="c"># It is important to yield *here* in order to stop the</span></td>
541 </tr>
543 </tr>
542 <tr id="l14" class="thisrev">
544 <tr id="l14" class="thisrev">
543 <td class="annotate parity0">
545 <td class="annotate parity0">
544
546
545 <div class="annotate-info">
547 <div class="annotate-info">
546 <div>
548 <div>
547 <a href="/annotate/f4fca47b67e6/primes.py#l14">
549 <a href="/annotate/687f2d169546/primes.py#l14">
548 f4fca47b67e6</a>
550 687f2d169546</a>
549 a
551 a
550 </div>
552 </div>
551 <div><em>&#116;&#101;&#115;&#116;</em></div>
553 <div><em>&#116;&#101;&#115;&#116;</em></div>
552 <div>parents: </div>
554 <div>parents: </div>
553 <a href="/diff/f4fca47b67e6/primes.py">diff</a>
555 <a href="/diff/687f2d169546/primes.py">diff</a>
554 <a href="/rev/f4fca47b67e6">changeset</a>
556 <a href="/rev/687f2d169546">changeset</a>
555 </div>
557 </div>
556 </td>
558 </td>
557 <td class="source followlines-btn-parent"><a href="#l14"> 14</a> <span class="c"># infinite recursion.</span></td>
559 <td class="source followlines-btn-parent"><a href="#l14"> 14</a> <span class="c"># infinite recursion.</span></td>
558 </tr>
560 </tr>
559 <tr id="l15" class="thisrev">
561 <tr id="l15" class="thisrev">
560 <td class="annotate parity0">
562 <td class="annotate parity0">
561
563
562 <div class="annotate-info">
564 <div class="annotate-info">
563 <div>
565 <div>
564 <a href="/annotate/f4fca47b67e6/primes.py#l15">
566 <a href="/annotate/687f2d169546/primes.py#l15">
565 f4fca47b67e6</a>
567 687f2d169546</a>
566 a
568 a
567 </div>
569 </div>
568 <div><em>&#116;&#101;&#115;&#116;</em></div>
570 <div><em>&#116;&#101;&#115;&#116;</em></div>
569 <div>parents: </div>
571 <div>parents: </div>
570 <a href="/diff/f4fca47b67e6/primes.py">diff</a>
572 <a href="/diff/687f2d169546/primes.py">diff</a>
571 <a href="/rev/f4fca47b67e6">changeset</a>
573 <a href="/rev/687f2d169546">changeset</a>
572 </div>
574 </div>
573 </td>
575 </td>
574 <td class="source followlines-btn-parent"><a href="#l15"> 15</a> <span class="kn">yield</span> <span class="n">p</span></td>
576 <td class="source followlines-btn-parent"><a href="#l15"> 15</a> <span class="kn">yield</span> <span class="n">p</span></td>
575 </tr>
577 </tr>
576 <tr id="l16" class="thisrev">
578 <tr id="l16" class="thisrev">
577 <td class="annotate parity0">
579 <td class="annotate parity0">
578
580
579 <div class="annotate-info">
581 <div class="annotate-info">
580 <div>
582 <div>
581 <a href="/annotate/f4fca47b67e6/primes.py#l16">
583 <a href="/annotate/687f2d169546/primes.py#l16">
582 f4fca47b67e6</a>
584 687f2d169546</a>
583 a
585 a
584 </div>
586 </div>
585 <div><em>&#116;&#101;&#115;&#116;</em></div>
587 <div><em>&#116;&#101;&#115;&#116;</em></div>
586 <div>parents: </div>
588 <div>parents: </div>
587 <a href="/diff/f4fca47b67e6/primes.py">diff</a>
589 <a href="/diff/687f2d169546/primes.py">diff</a>
588 <a href="/rev/f4fca47b67e6">changeset</a>
590 <a href="/rev/687f2d169546">changeset</a>
589 </div>
591 </div>
590 </td>
592 </td>
591 <td class="source followlines-btn-parent"><a href="#l16"> 16</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>
593 <td class="source followlines-btn-parent"><a href="#l16"> 16</a> <span class="n">ns</span> <span class="o">=</span> <span class="n">itertools</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>
592 </tr>
594 </tr>
593 <tr id="l17" class="thisrev">
595 <tr id="l17" class="thisrev">
594 <td class="annotate parity0">
596 <td class="annotate parity0">
595
597
596 <div class="annotate-info">
598 <div class="annotate-info">
597 <div>
599 <div>
598 <a href="/annotate/f4fca47b67e6/primes.py#l17">
600 <a href="/annotate/687f2d169546/primes.py#l17">
599 f4fca47b67e6</a>
601 687f2d169546</a>
600 a
602 a
601 </div>
603 </div>
602 <div><em>&#116;&#101;&#115;&#116;</em></div>
604 <div><em>&#116;&#101;&#115;&#116;</em></div>
603 <div>parents: </div>
605 <div>parents: </div>
604 <a href="/diff/f4fca47b67e6/primes.py">diff</a>
606 <a href="/diff/687f2d169546/primes.py">diff</a>
605 <a href="/rev/f4fca47b67e6">changeset</a>
607 <a href="/rev/687f2d169546">changeset</a>
606 </div>
608 </div>
607 </td>
609 </td>
608 <td class="source followlines-btn-parent"><a href="#l17"> 17</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>
610 <td class="source followlines-btn-parent"><a href="#l17"> 17</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>
609 </tr>
611 </tr>
610 <tr id="l18" class="thisrev">
612 <tr id="l18" class="thisrev">
611 <td class="annotate parity0">
613 <td class="annotate parity0">
612
614
613 <div class="annotate-info">
615 <div class="annotate-info">
614 <div>
616 <div>
615 <a href="/annotate/f4fca47b67e6/primes.py#l18">
617 <a href="/annotate/687f2d169546/primes.py#l18">
616 f4fca47b67e6</a>
618 687f2d169546</a>
617 a
619 a
618 </div>
620 </div>
619 <div><em>&#116;&#101;&#115;&#116;</em></div>
621 <div><em>&#116;&#101;&#115;&#116;</em></div>
620 <div>parents: </div>
622 <div>parents: </div>
621 <a href="/diff/f4fca47b67e6/primes.py">diff</a>
623 <a href="/diff/687f2d169546/primes.py">diff</a>
622 <a href="/rev/f4fca47b67e6">changeset</a>
624 <a href="/rev/687f2d169546">changeset</a>
623 </div>
625 </div>
624 </td>
626 </td>
625 <td class="source followlines-btn-parent"><a href="#l18"> 18</a> <span class="kn">yield</span> <span class="n">n</span></td>
627 <td class="source followlines-btn-parent"><a href="#l18"> 18</a> <span class="kn">yield</span> <span class="n">n</span></td>
626 </tr>
628 </tr>
627 <tr id="l19" class="thisrev">
629 <tr id="l19" class="thisrev">
628 <td class="annotate parity0">
630 <td class="annotate parity0">
629
631
630 <div class="annotate-info">
632 <div class="annotate-info">
631 <div>
633 <div>
632 <a href="/annotate/f4fca47b67e6/primes.py#l19">
634 <a href="/annotate/687f2d169546/primes.py#l19">
633 f4fca47b67e6</a>
635 687f2d169546</a>
634 a
636 a
635 </div>
637 </div>
636 <div><em>&#116;&#101;&#115;&#116;</em></div>
638 <div><em>&#116;&#101;&#115;&#116;</em></div>
637 <div>parents: </div>
639 <div>parents: </div>
638 <a href="/diff/f4fca47b67e6/primes.py">diff</a>
640 <a href="/diff/687f2d169546/primes.py">diff</a>
639 <a href="/rev/f4fca47b67e6">changeset</a>
641 <a href="/rev/687f2d169546">changeset</a>
640 </div>
642 </div>
641 </td>
643 </td>
642 <td class="source followlines-btn-parent"><a href="#l19"> 19</a> </td>
644 <td class="source followlines-btn-parent"><a href="#l19"> 19</a> </td>
643 </tr>
645 </tr>
644 <tr id="l20" class="thisrev">
646 <tr id="l20" class="thisrev">
645 <td class="annotate parity0">
647 <td class="annotate parity0">
646
648
647 <div class="annotate-info">
649 <div class="annotate-info">
648 <div>
650 <div>
649 <a href="/annotate/f4fca47b67e6/primes.py#l20">
651 <a href="/annotate/687f2d169546/primes.py#l20">
650 f4fca47b67e6</a>
652 687f2d169546</a>
651 a
653 a
652 </div>
654 </div>
653 <div><em>&#116;&#101;&#115;&#116;</em></div>
655 <div><em>&#116;&#101;&#115;&#116;</em></div>
654 <div>parents: </div>
656 <div>parents: </div>
655 <a href="/diff/f4fca47b67e6/primes.py">diff</a>
657 <a href="/diff/687f2d169546/primes.py">diff</a>
656 <a href="/rev/f4fca47b67e6">changeset</a>
658 <a href="/rev/687f2d169546">changeset</a>
657 </div>
659 </div>
658 </td>
660 </td>
659 <td class="source followlines-btn-parent"><a href="#l20"> 20</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>
661 <td class="source followlines-btn-parent"><a href="#l20"> 20</a> <span class="n">odds</span> <span class="o">=</span> <span class="n">itertools</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">itertools</span><span class="o">.</span><span class="n">count</span><span class="p">())</span></td>
660 </tr>
662 </tr>
661 <tr id="l21" class="thisrev">
663 <tr id="l21" class="thisrev">
662 <td class="annotate parity0">
664 <td class="annotate parity0">
663
665
664 <div class="annotate-info">
666 <div class="annotate-info">
665 <div>
667 <div>
666 <a href="/annotate/f4fca47b67e6/primes.py#l21">
668 <a href="/annotate/687f2d169546/primes.py#l21">
667 f4fca47b67e6</a>
669 687f2d169546</a>
668 a
670 a
669 </div>
671 </div>
670 <div><em>&#116;&#101;&#115;&#116;</em></div>
672 <div><em>&#116;&#101;&#115;&#116;</em></div>
671 <div>parents: </div>
673 <div>parents: </div>
672 <a href="/diff/f4fca47b67e6/primes.py">diff</a>
674 <a href="/diff/687f2d169546/primes.py">diff</a>
673 <a href="/rev/f4fca47b67e6">changeset</a>
675 <a href="/rev/687f2d169546">changeset</a>
674 </div>
676 </div>
675 </td>
677 </td>
676 <td class="source followlines-btn-parent"><a href="#l21"> 21</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">&lt;</span> <span class="mi">3</span><span class="p">,</span> <span class="n">odds</span><span class="p">)))</span></td>
678 <td class="source followlines-btn-parent"><a href="#l21"> 21</a> <span class="n">dropwhile</span> <span class="o">=</span> <span class="n">itertools</span><span class="o">.</span><span class="n">dropwhile</span></td>
677 </tr>
679 </tr>
678 <tr id="l22" class="thisrev">
680 <tr id="l22" class="thisrev">
679 <td class="annotate parity0">
681 <td class="annotate parity0">
680
682
681 <div class="annotate-info">
683 <div class="annotate-info">
682 <div>
684 <div>
683 <a href="/annotate/f4fca47b67e6/primes.py#l22">
685 <a href="/annotate/687f2d169546/primes.py#l22">
684 f4fca47b67e6</a>
686 687f2d169546</a>
685 a
687 a
686 </div>
688 </div>
687 <div><em>&#116;&#101;&#115;&#116;</em></div>
689 <div><em>&#116;&#101;&#115;&#116;</em></div>
688 <div>parents: </div>
690 <div>parents: </div>
689 <a href="/diff/f4fca47b67e6/primes.py">diff</a>
691 <a href="/diff/687f2d169546/primes.py">diff</a>
690 <a href="/rev/f4fca47b67e6">changeset</a>
692 <a href="/rev/687f2d169546">changeset</a>
691 </div>
693 </div>
692 </td>
694 </td>
693 <td class="source followlines-btn-parent"><a href="#l22"> 22</a> </td>
695 <td class="source followlines-btn-parent"><a href="#l22"> 22</a> <span class="kn">return</span> <span class="n">itertools</span><span class="o">.</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">&lt;</span> <span class="mi">3</span><span class="p">,</span> <span class="n">odds</span><span class="p">)))</span></td>
694 </tr>
696 </tr>
695 <tr id="l23" class="thisrev">
697 <tr id="l23" class="thisrev">
696 <td class="annotate parity0">
698 <td class="annotate parity0">
697
699
698 <div class="annotate-info">
700 <div class="annotate-info">
699 <div>
701 <div>
700 <a href="/annotate/f4fca47b67e6/primes.py#l23">
702 <a href="/annotate/687f2d169546/primes.py#l23">
701 f4fca47b67e6</a>
703 687f2d169546</a>
702 a
704 a
703 </div>
705 </div>
704 <div><em>&#116;&#101;&#115;&#116;</em></div>
706 <div><em>&#116;&#101;&#115;&#116;</em></div>
705 <div>parents: </div>
707 <div>parents: </div>
706 <a href="/diff/f4fca47b67e6/primes.py">diff</a>
708 <a href="/diff/687f2d169546/primes.py">diff</a>
707 <a href="/rev/f4fca47b67e6">changeset</a>
709 <a href="/rev/687f2d169546">changeset</a>
708 </div>
710 </div>
709 </td>
711 </td>
710 <td class="source followlines-btn-parent"><a href="#l23"> 23</a> <span class="kn">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">&quot;__main__&quot;</span><span class="p">:</span></td>
712 <td class="source followlines-btn-parent"><a href="#l23"> 23</a> </td>
711 </tr>
713 </tr>
712 <tr id="l24" class="thisrev">
714 <tr id="l24" class="thisrev">
713 <td class="annotate parity0">
715 <td class="annotate parity0">
714
716
715 <div class="annotate-info">
717 <div class="annotate-info">
716 <div>
718 <div>
717 <a href="/annotate/f4fca47b67e6/primes.py#l24">
719 <a href="/annotate/687f2d169546/primes.py#l24">
718 f4fca47b67e6</a>
720 687f2d169546</a>
719 a
721 a
720 </div>
722 </div>
721 <div><em>&#116;&#101;&#115;&#116;</em></div>
723 <div><em>&#116;&#101;&#115;&#116;</em></div>
722 <div>parents: </div>
724 <div>parents: </div>
723 <a href="/diff/f4fca47b67e6/primes.py">diff</a>
725 <a href="/diff/687f2d169546/primes.py">diff</a>
724 <a href="/rev/f4fca47b67e6">changeset</a>
726 <a href="/rev/687f2d169546">changeset</a>
725 </div>
727 </div>
726 </td>
728 </td>
727 <td class="source followlines-btn-parent"><a href="#l24"> 24</a> <span class="kn">import</span> <span class="nn">sys</span></td>
729 <td class="source followlines-btn-parent"><a href="#l24"> 24</a> <span class="kn">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">&quot;__main__&quot;</span><span class="p">:</span></td>
728 </tr>
730 </tr>
729 <tr id="l25" class="thisrev">
731 <tr id="l25" class="thisrev">
730 <td class="annotate parity0">
732 <td class="annotate parity0">
731
733
732 <div class="annotate-info">
734 <div class="annotate-info">
733 <div>
735 <div>
734 <a href="/annotate/f4fca47b67e6/primes.py#l25">
736 <a href="/annotate/687f2d169546/primes.py#l25">
735 f4fca47b67e6</a>
737 687f2d169546</a>
736 a
738 a
737 </div>
739 </div>
738 <div><em>&#116;&#101;&#115;&#116;</em></div>
740 <div><em>&#116;&#101;&#115;&#116;</em></div>
739 <div>parents: </div>
741 <div>parents: </div>
740 <a href="/diff/f4fca47b67e6/primes.py">diff</a>
742 <a href="/diff/687f2d169546/primes.py">diff</a>
741 <a href="/rev/f4fca47b67e6">changeset</a>
743 <a href="/rev/687f2d169546">changeset</a>
742 </div>
744 </div>
743 </td>
745 </td>
744 <td class="source followlines-btn-parent"><a href="#l25"> 25</a> <span class="kn">try</span><span class="p">:</span></td>
746 <td class="source followlines-btn-parent"><a href="#l25"> 25</a> <span class="kn">import</span> <span class="nn">sys</span></td>
745 </tr>
747 </tr>
746 <tr id="l26" class="thisrev">
748 <tr id="l26" class="thisrev">
747 <td class="annotate parity0">
749 <td class="annotate parity0">
748
750
749 <div class="annotate-info">
751 <div class="annotate-info">
750 <div>
752 <div>
751 <a href="/annotate/f4fca47b67e6/primes.py#l26">
753 <a href="/annotate/687f2d169546/primes.py#l26">
752 f4fca47b67e6</a>
754 687f2d169546</a>
753 a
755 a
754 </div>
756 </div>
755 <div><em>&#116;&#101;&#115;&#116;</em></div>
757 <div><em>&#116;&#101;&#115;&#116;</em></div>
756 <div>parents: </div>
758 <div>parents: </div>
757 <a href="/diff/f4fca47b67e6/primes.py">diff</a>
759 <a href="/diff/687f2d169546/primes.py">diff</a>
758 <a href="/rev/f4fca47b67e6">changeset</a>
760 <a href="/rev/687f2d169546">changeset</a>
759 </div>
761 </div>
760 </td>
762 </td>
761 <td class="source followlines-btn-parent"><a href="#l26"> 26</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>
763 <td class="source followlines-btn-parent"><a href="#l26"> 26</a> <span class="kn">try</span><span class="p">:</span></td>
762 </tr>
764 </tr>
763 <tr id="l27" class="thisrev">
765 <tr id="l27" class="thisrev">
764 <td class="annotate parity0">
766 <td class="annotate parity0">
765
767
766 <div class="annotate-info">
768 <div class="annotate-info">
767 <div>
769 <div>
768 <a href="/annotate/f4fca47b67e6/primes.py#l27">
770 <a href="/annotate/687f2d169546/primes.py#l27">
769 f4fca47b67e6</a>
771 687f2d169546</a>
770 a
772 a
771 </div>
773 </div>
772 <div><em>&#116;&#101;&#115;&#116;</em></div>
774 <div><em>&#116;&#101;&#115;&#116;</em></div>
773 <div>parents: </div>
775 <div>parents: </div>
774 <a href="/diff/f4fca47b67e6/primes.py">diff</a>
776 <a href="/diff/687f2d169546/primes.py">diff</a>
775 <a href="/rev/f4fca47b67e6">changeset</a>
777 <a href="/rev/687f2d169546">changeset</a>
776 </div>
778 </div>
777 </td>
779 </td>
778 <td class="source followlines-btn-parent"><a href="#l27"> 27</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>
780 <td class="source followlines-btn-parent"><a href="#l27"> 27</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>
779 </tr>
781 </tr>
780 <tr id="l28" class="thisrev">
782 <tr id="l28" class="thisrev">
781 <td class="annotate parity0">
783 <td class="annotate parity0">
782
784
783 <div class="annotate-info">
785 <div class="annotate-info">
784 <div>
786 <div>
785 <a href="/annotate/f4fca47b67e6/primes.py#l28">
787 <a href="/annotate/687f2d169546/primes.py#l28">
786 f4fca47b67e6</a>
788 687f2d169546</a>
787 a
789 a
788 </div>
790 </div>
789 <div><em>&#116;&#101;&#115;&#116;</em></div>
791 <div><em>&#116;&#101;&#115;&#116;</em></div>
790 <div>parents: </div>
792 <div>parents: </div>
791 <a href="/diff/f4fca47b67e6/primes.py">diff</a>
793 <a href="/diff/687f2d169546/primes.py">diff</a>
792 <a href="/rev/f4fca47b67e6">changeset</a>
794 <a href="/rev/687f2d169546">changeset</a>
793 </div>
795 </div>
794 </td>
796 </td>
795 <td class="source followlines-btn-parent"><a href="#l28"> 28</a> <span class="n">n</span> <span class="o">=</span> <span class="mi">10</span></td>
797 <td class="source followlines-btn-parent"><a href="#l28"> 28</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>
796 </tr>
798 </tr>
797 <tr id="l29" class="thisrev">
799 <tr id="l29" class="thisrev">
798 <td class="annotate parity0">
800 <td class="annotate parity0">
799
801
800 <div class="annotate-info">
802 <div class="annotate-info">
801 <div>
803 <div>
802 <a href="/annotate/f4fca47b67e6/primes.py#l29">
804 <a href="/annotate/687f2d169546/primes.py#l29">
803 f4fca47b67e6</a>
805 687f2d169546</a>
804 a
806 a
805 </div>
807 </div>
806 <div><em>&#116;&#101;&#115;&#116;</em></div>
808 <div><em>&#116;&#101;&#115;&#116;</em></div>
807 <div>parents: </div>
809 <div>parents: </div>
808 <a href="/diff/f4fca47b67e6/primes.py">diff</a>
810 <a href="/diff/687f2d169546/primes.py">diff</a>
809 <a href="/rev/f4fca47b67e6">changeset</a>
811 <a href="/rev/687f2d169546">changeset</a>
810 </div>
812 </div>
811 </td>
813 </td>
812 <td class="source followlines-btn-parent"><a href="#l29"> 29</a> <span class="n">p</span> <span class="o">=</span> <span class="n">primes</span><span class="p">()</span></td>
814 <td class="source followlines-btn-parent"><a href="#l29"> 29</a> <span class="n">n</span> <span class="o">=</span> <span class="mi">10</span></td>
813 </tr>
815 </tr>
814 <tr id="l30" class="thisrev">
816 <tr id="l30" class="thisrev">
815 <td class="annotate parity0">
817 <td class="annotate parity0">
816
818
817 <div class="annotate-info">
819 <div class="annotate-info">
818 <div>
820 <div>
819 <a href="/annotate/f4fca47b67e6/primes.py#l30">
821 <a href="/annotate/687f2d169546/primes.py#l30">
820 f4fca47b67e6</a>
822 687f2d169546</a>
821 a
823 a
822 </div>
824 </div>
823 <div><em>&#116;&#101;&#115;&#116;</em></div>
825 <div><em>&#116;&#101;&#115;&#116;</em></div>
824 <div>parents: </div>
826 <div>parents: </div>
825 <a href="/diff/f4fca47b67e6/primes.py">diff</a>
827 <a href="/diff/687f2d169546/primes.py">diff</a>
826 <a href="/rev/f4fca47b67e6">changeset</a>
828 <a href="/rev/687f2d169546">changeset</a>
827 </div>
829 </div>
828 </td>
830 </td>
829 <td class="source followlines-btn-parent"><a href="#l30"> 30</a> <span class="kn">print</span><span class="p">(</span><span class="s">&quot;The first </span><span class="si">%d</span><span class="s"> primes: </span><span class="si">%s</span><span class="s">&quot;</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>
831 <td class="source followlines-btn-parent"><a href="#l30"> 30</a> <span class="n">p</span> <span class="o">=</span> <span class="n">primes</span><span class="p">()</span></td>
830 </tr>
832 </tr>
831 <tr id="l31" class="thisrev">
833 <tr id="l31" class="thisrev">
832 <td class="annotate parity0">
834 <td class="annotate parity0">
833
835
834 <div class="annotate-info">
836 <div class="annotate-info">
835 <div>
837 <div>
836 <a href="/annotate/f4fca47b67e6/primes.py#l31">
838 <a href="/annotate/687f2d169546/primes.py#l31">
837 f4fca47b67e6</a>
839 687f2d169546</a>
838 a
840 a
839 </div>
841 </div>
840 <div><em>&#116;&#101;&#115;&#116;</em></div>
842 <div><em>&#116;&#101;&#115;&#116;</em></div>
841 <div>parents: </div>
843 <div>parents: </div>
842 <a href="/diff/f4fca47b67e6/primes.py">diff</a>
844 <a href="/diff/687f2d169546/primes.py">diff</a>
843 <a href="/rev/f4fca47b67e6">changeset</a>
845 <a href="/rev/687f2d169546">changeset</a>
844 </div>
846 </div>
845 </td>
847 </td>
846 <td class="source followlines-btn-parent"><a href="#l31"> 31</a> </td>
848 <td class="source followlines-btn-parent"><a href="#l31"> 31</a> <span class="kn">print</span><span class="p">(</span><span class="s">&quot;The first </span><span class="si">%d</span><span class="s"> primes: </span><span class="si">%s</span><span class="s">&quot;</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">itertools</span><span class="o">.</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>
849 </tr>
850 <tr id="l32" class="thisrev">
851 <td class="annotate parity0">
852
853 <div class="annotate-info">
854 <div>
855 <a href="/annotate/687f2d169546/primes.py#l32">
856 687f2d169546</a>
857 a
858 </div>
859 <div><em>&#116;&#101;&#115;&#116;</em></div>
860 <div>parents: </div>
861 <a href="/diff/687f2d169546/primes.py">diff</a>
862 <a href="/rev/687f2d169546">changeset</a>
863 </div>
864 </td>
865 <td class="source followlines-btn-parent"><a href="#l32"> 32</a> </td>
847 </tr>
866 </tr>
848 </tbody>
867 </tbody>
849 </table>
868 </table>
850 </div>
869 </div>
851 </div>
870 </div>
852 </div>
871 </div>
853
872
854 <script type="text/javascript" src="/static/followlines.js"></script>
873 <script type="text/javascript" src="/static/followlines.js"></script>
855
874
856
875
857
876
858 </body>
877 </body>
859 </html>
878 </html>
860
879
861
880
862 hgweb fileannotate, raw
881 hgweb fileannotate, raw
863
882
864 $ (get-with-headers.py localhost:$HGPORT 'annotate/tip/primes.py?style=raw') \
883 $ (get-with-headers.py localhost:$HGPORT 'annotate/tip/primes.py?style=raw') \
865 > | sed "s/test@//" > a
884 > | sed "s/test@//" > a
866 $ echo "200 Script output follows" > b
885 $ echo "200 Script output follows" > b
867 $ echo "" >> b
886 $ echo "" >> b
868 $ echo "" >> b
887 $ echo "" >> b
869 $ hg annotate "primes.py" >> b
888 $ hg annotate "primes.py" >> b
870 $ echo "" >> b
889 $ echo "" >> b
871 $ echo "" >> b
890 $ echo "" >> b
872 $ echo "" >> b
891 $ echo "" >> b
873 $ echo "" >> b
892 $ echo "" >> b
874 $ cmp b a || diff -u b a
893 $ cmp b a || diff -u b a
875
894
876 hgweb filerevision, raw
895 hgweb filerevision, raw
877
896
878 $ (get-with-headers.py localhost:$HGPORT 'file/tip/primes.py?style=raw') \
897 $ (get-with-headers.py localhost:$HGPORT 'file/tip/primes.py?style=raw') \
879 > > a
898 > > a
880 $ echo "200 Script output follows" > b
899 $ echo "200 Script output follows" > b
881 $ echo "" >> b
900 $ echo "" >> b
882 $ hg cat primes.py >> b
901 $ hg cat primes.py >> b
883 $ cmp b a || diff -u b a
902 $ cmp b a || diff -u b a
884
903
885 hgweb highlightcss friendly
904 hgweb highlightcss friendly
886
905
887 $ get-with-headers.py localhost:$HGPORT 'highlightcss' > out
906 $ get-with-headers.py localhost:$HGPORT 'highlightcss' > out
888 $ head -n 4 out
907 $ head -n 4 out
889 200 Script output follows
908 200 Script output follows
890
909
891 /* pygments_style = friendly */
910 /* pygments_style = friendly */
892
911
893 $ rm out
912 $ rm out
894
913
895 errors encountered
914 errors encountered
896
915
897 $ cat errors.log
916 $ cat errors.log
898 $ killdaemons.py
917 $ killdaemons.py
899
918
900 Change the pygments style
919 Change the pygments style
901
920
902 $ cat > .hg/hgrc <<EOF
921 $ cat > .hg/hgrc <<EOF
903 > [web]
922 > [web]
904 > pygments_style = fruity
923 > pygments_style = fruity
905 > EOF
924 > EOF
906
925
907 hg serve again
926 hg serve again
908
927
909 $ hg serve -p $HGPORT -d -n test --pid-file=hg.pid -A access.log -E errors.log
928 $ hg serve -p $HGPORT -d -n test --pid-file=hg.pid -A access.log -E errors.log
910 $ cat hg.pid >> $DAEMON_PIDS
929 $ cat hg.pid >> $DAEMON_PIDS
911
930
912 hgweb highlightcss fruity
931 hgweb highlightcss fruity
913
932
914 $ get-with-headers.py localhost:$HGPORT 'highlightcss' > out
933 $ get-with-headers.py localhost:$HGPORT 'highlightcss' > out
915 $ head -n 4 out
934 $ head -n 4 out
916 200 Script output follows
935 200 Script output follows
917
936
918 /* pygments_style = fruity */
937 /* pygments_style = fruity */
919
938
920 $ rm out
939 $ rm out
921
940
922 errors encountered
941 errors encountered
923
942
924 $ cat errors.log
943 $ cat errors.log
925 $ killdaemons.py
944 $ killdaemons.py
926
945
927 only highlight C source files
946 only highlight C source files
928
947
929 $ cat > .hg/hgrc <<EOF
948 $ cat > .hg/hgrc <<EOF
930 > [web]
949 > [web]
931 > highlightfiles = **.c
950 > highlightfiles = **.c
932 > EOF
951 > EOF
933
952
934 hg serve again
953 hg serve again
935
954
936 $ hg serve -p $HGPORT -d -n test --pid-file=hg.pid -A access.log -E errors.log
955 $ hg serve -p $HGPORT -d -n test --pid-file=hg.pid -A access.log -E errors.log
937 $ cat hg.pid >> $DAEMON_PIDS
956 $ cat hg.pid >> $DAEMON_PIDS
938
957
939 test that fileset in highlightfiles works and primes.py is not highlighted
958 test that fileset in highlightfiles works and primes.py is not highlighted
940
959
941 $ get-with-headers.py localhost:$HGPORT 'file/tip/primes.py' | grep 'id="l11"'
960 $ get-with-headers.py localhost:$HGPORT 'file/tip/primes.py' | grep 'id="l11"'
942 <span id="l11"> def sieve(ns):</span><a href="#l11"></a>
961 <span id="l11"> def sieve(ns):</span><a href="#l11"></a>
943
962
944 errors encountered
963 errors encountered
945
964
946 $ cat errors.log
965 $ cat errors.log
947 $ cd ..
966 $ cd ..
948 $ hg init eucjp
967 $ hg init eucjp
949 $ cd eucjp
968 $ cd eucjp
950 $ "$PYTHON" -c 'print("\265\376")' >> eucjp.txt # Japanese kanji "Kyo"
969 $ "$PYTHON" -c 'print("\265\376")' >> eucjp.txt # Japanese kanji "Kyo"
951 $ hg ci -Ama
970 $ hg ci -Ama
952 adding eucjp.txt
971 adding eucjp.txt
953 $ hgserveget () {
972 $ hgserveget () {
954 > killdaemons.py
973 > killdaemons.py
955 > echo % HGENCODING="$1" hg serve
974 > echo % HGENCODING="$1" hg serve
956 > HGENCODING="$1" hg serve -p $HGPORT -d -n test --pid-file=hg.pid -E errors.log
975 > HGENCODING="$1" hg serve -p $HGPORT -d -n test --pid-file=hg.pid -E errors.log
957 > cat hg.pid >> $DAEMON_PIDS
976 > cat hg.pid >> $DAEMON_PIDS
958 >
977 >
959 > echo % hgweb filerevision, html
978 > echo % hgweb filerevision, html
960 > get-with-headers.py localhost:$HGPORT "file/tip/$2" \
979 > get-with-headers.py localhost:$HGPORT "file/tip/$2" \
961 > | grep '<div class="parity0 source">'
980 > | grep '<div class="parity0 source">'
962 > echo % errors encountered
981 > echo % errors encountered
963 > cat errors.log
982 > cat errors.log
964 > }
983 > }
965 $ hgserveget euc-jp eucjp.txt
984 $ hgserveget euc-jp eucjp.txt
966 % HGENCODING=euc-jp hg serve
985 % HGENCODING=euc-jp hg serve
967 % hgweb filerevision, html
986 % hgweb filerevision, html
968 % errors encountered
987 % errors encountered
969 $ hgserveget utf-8 eucjp.txt
988 $ hgserveget utf-8 eucjp.txt
970 % HGENCODING=utf-8 hg serve
989 % HGENCODING=utf-8 hg serve
971 % hgweb filerevision, html
990 % hgweb filerevision, html
972 % errors encountered
991 % errors encountered
973 $ hgserveget us-ascii eucjp.txt
992 $ hgserveget us-ascii eucjp.txt
974 % HGENCODING=us-ascii hg serve
993 % HGENCODING=us-ascii hg serve
975 % hgweb filerevision, html
994 % hgweb filerevision, html
976 % errors encountered
995 % errors encountered
977
996
978 We attempt to highlight unknown files by default
997 We attempt to highlight unknown files by default
979
998
980 $ killdaemons.py
999 $ killdaemons.py
981
1000
982 $ cat > .hg/hgrc << EOF
1001 $ cat > .hg/hgrc << EOF
983 > [web]
1002 > [web]
984 > highlightfiles = **
1003 > highlightfiles = **
985 > EOF
1004 > EOF
986
1005
987 $ cat > unknownfile << EOF
1006 $ cat > unknownfile << EOF
988 > #!$PYTHON
1007 > #!$PYTHON
989 > def foo():
1008 > def foo():
990 > pass
1009 > pass
991 > EOF
1010 > EOF
992
1011
993 $ hg add unknownfile
1012 $ hg add unknownfile
994 $ hg commit -m unknown unknownfile
1013 $ hg commit -m unknown unknownfile
995
1014
996 $ hg serve -p $HGPORT -d -n test --pid-file=hg.pid
1015 $ hg serve -p $HGPORT -d -n test --pid-file=hg.pid
997 $ cat hg.pid >> $DAEMON_PIDS
1016 $ cat hg.pid >> $DAEMON_PIDS
998
1017
999 $ get-with-headers.py localhost:$HGPORT 'file/tip/unknownfile' | grep l2
1018 $ get-with-headers.py localhost:$HGPORT 'file/tip/unknownfile' | grep l2
1000 <span id="l2"><span class="k">def</span> <span class="nf">foo</span><span class="p">():</span></span><a href="#l2"></a>
1019 <span id="l2"><span class="k">def</span> <span class="nf">foo</span><span class="p">():</span></span><a href="#l2"></a>
1001
1020
1002 We can prevent Pygments from falling back to a non filename-based
1021 We can prevent Pygments from falling back to a non filename-based
1003 detection mode
1022 detection mode
1004
1023
1005 $ cat > .hg/hgrc << EOF
1024 $ cat > .hg/hgrc << EOF
1006 > [web]
1025 > [web]
1007 > highlightfiles = **
1026 > highlightfiles = **
1008 > highlightonlymatchfilename = true
1027 > highlightonlymatchfilename = true
1009 > EOF
1028 > EOF
1010
1029
1011 $ killdaemons.py
1030 $ killdaemons.py
1012 $ hg serve -p $HGPORT -d -n test --pid-file=hg.pid
1031 $ hg serve -p $HGPORT -d -n test --pid-file=hg.pid
1013 $ cat hg.pid >> $DAEMON_PIDS
1032 $ cat hg.pid >> $DAEMON_PIDS
1014 $ get-with-headers.py localhost:$HGPORT 'file/tip/unknownfile' | grep l2
1033 $ get-with-headers.py localhost:$HGPORT 'file/tip/unknownfile' | grep l2
1015 <span id="l2">def foo():</span><a href="#l2"></a>
1034 <span id="l2">def foo():</span><a href="#l2"></a>
1016
1035
1017 $ cd ..
1036 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now