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