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