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