Show More
@@ -1,686 +1,686 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 | create random Python file to exercise Pygments |
|
13 | create random Python file to exercise Pygments | |
14 |
|
14 | |||
15 | $ cat <<EOF > primes.py |
|
15 | $ cat <<EOF > primes.py | |
16 | > #!/usr/bin/env python |
|
16 | > #!/usr/bin/env python | |
17 | > |
|
17 | > | |
18 | > """Fun with generators. Corresponding Haskell implementation: |
|
18 | > """Fun with generators. Corresponding Haskell implementation: | |
19 | > |
|
19 | > | |
20 | > primes = 2 : sieve [3, 5..] |
|
20 | > primes = 2 : sieve [3, 5..] | |
21 | > where sieve (p:ns) = p : sieve [n | n <- ns, mod n p /= 0] |
|
21 | > where sieve (p:ns) = p : sieve [n | n <- ns, mod n p /= 0] | |
22 | > """ |
|
22 | > """ | |
23 | > |
|
23 | > | |
24 | > from itertools import dropwhile, ifilter, islice, count, chain |
|
24 | > from itertools import dropwhile, ifilter, islice, count, chain | |
25 | > |
|
25 | > | |
26 | > def primes(): |
|
26 | > def primes(): | |
27 | > """Generate all primes.""" |
|
27 | > """Generate all primes.""" | |
28 | > def sieve(ns): |
|
28 | > def sieve(ns): | |
29 | > p = ns.next() |
|
29 | > p = ns.next() | |
30 | > # It is important to yield *here* in order to stop the |
|
30 | > # It is important to yield *here* in order to stop the | |
31 | > # infinite recursion. |
|
31 | > # infinite recursion. | |
32 | > yield p |
|
32 | > yield p | |
33 | > ns = ifilter(lambda n: n % p != 0, ns) |
|
33 | > ns = ifilter(lambda n: n % p != 0, ns) | |
34 | > for n in sieve(ns): |
|
34 | > for n in sieve(ns): | |
35 | > yield n |
|
35 | > yield n | |
36 | > |
|
36 | > | |
37 | > odds = ifilter(lambda i: i % 2 == 1, count()) |
|
37 | > odds = ifilter(lambda i: i % 2 == 1, count()) | |
38 | > return chain([2], sieve(dropwhile(lambda n: n < 3, odds))) |
|
38 | > return chain([2], sieve(dropwhile(lambda n: n < 3, odds))) | |
39 | > |
|
39 | > | |
40 | > if __name__ == "__main__": |
|
40 | > if __name__ == "__main__": | |
41 | > import sys |
|
41 | > import sys | |
42 | > try: |
|
42 | > try: | |
43 | > n = int(sys.argv[1]) |
|
43 | > n = int(sys.argv[1]) | |
44 | > except (ValueError, IndexError): |
|
44 | > except (ValueError, IndexError): | |
45 | > n = 10 |
|
45 | > n = 10 | |
46 | > p = primes() |
|
46 | > p = primes() | |
47 | > print "The first %d primes: %s" % (n, list(islice(p, n))) |
|
47 | > print "The first %d primes: %s" % (n, list(islice(p, n))) | |
48 | > EOF |
|
48 | > EOF | |
49 | $ echo >> primes.py # to test html markup with an empty line just before EOF |
|
49 | $ echo >> primes.py # to test html markup with an empty line just before EOF | |
50 | $ hg ci -Ama |
|
50 | $ hg ci -Ama | |
51 | adding primes.py |
|
51 | adding primes.py | |
52 |
|
52 | |||
53 | hg serve |
|
53 | hg serve | |
54 |
|
54 | |||
55 | $ hg serve -p $HGPORT -d -n test --pid-file=hg.pid -A access.log -E errors.log |
|
55 | $ hg serve -p $HGPORT -d -n test --pid-file=hg.pid -A access.log -E errors.log | |
56 | $ cat hg.pid >> $DAEMON_PIDS |
|
56 | $ cat hg.pid >> $DAEMON_PIDS | |
57 |
|
57 | |||
58 | hgweb filerevision, html |
|
58 | hgweb filerevision, html | |
59 |
|
59 | |||
60 | $ (get-with-headers.py localhost:$HGPORT 'file/tip/primes.py') \ |
|
60 | $ (get-with-headers.py localhost:$HGPORT 'file/tip/primes.py') \ | |
61 | > | sed "s/class=\"k\"/class=\"kn\"/g" | sed "s/class=\"mf\"/class=\"mi\"/g" |
|
61 | > | sed "s/class=\"k\"/class=\"kn\"/g" | sed "s/class=\"mf\"/class=\"mi\"/g" | |
62 | 200 Script output follows |
|
62 | 200 Script output follows | |
63 |
|
63 | |||
64 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
|
64 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> | |
65 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US"> |
|
65 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US"> | |
66 | <head> |
|
66 | <head> | |
67 | <link rel="icon" href="/static/hgicon.png" type="image/png" /> |
|
67 | <link rel="icon" href="/static/hgicon.png" type="image/png" /> | |
68 | <meta name="robots" content="index, nofollow" /> |
|
68 | <meta name="robots" content="index, nofollow" /> | |
69 | <link rel="stylesheet" href="/static/style-paper.css" type="text/css" /> |
|
69 | <link rel="stylesheet" href="/static/style-paper.css" type="text/css" /> | |
70 | <script type="text/javascript" src="/static/mercurial.js"></script> |
|
70 | <script type="text/javascript" src="/static/mercurial.js"></script> | |
71 |
|
71 | |||
72 | <link rel="stylesheet" href="/highlightcss" type="text/css" /> |
|
72 | <link rel="stylesheet" href="/highlightcss" type="text/css" /> | |
73 | <title>test: 06824edf55d0 primes.py</title> |
|
73 | <title>test: 06824edf55d0 primes.py</title> | |
74 | </head> |
|
74 | </head> | |
75 | <body> |
|
75 | <body> | |
76 |
|
76 | |||
77 | <div class="container"> |
|
77 | <div class="container"> | |
78 | <div class="menu"> |
|
78 | <div class="menu"> | |
79 | <div class="logo"> |
|
79 | <div class="logo"> | |
80 | <a href="https://mercurial-scm.org/"> |
|
80 | <a href="https://mercurial-scm.org/"> | |
81 | <img src="/static/hglogo.png" alt="mercurial" /></a> |
|
81 | <img src="/static/hglogo.png" alt="mercurial" /></a> | |
82 | </div> |
|
82 | </div> | |
83 | <ul> |
|
83 | <ul> | |
84 | <li><a href="/shortlog/tip">log</a></li> |
|
84 | <li><a href="/shortlog/tip">log</a></li> | |
85 | <li><a href="/graph/tip">graph</a></li> |
|
85 | <li><a href="/graph/tip">graph</a></li> | |
86 | <li><a href="/tags">tags</a></li> |
|
86 | <li><a href="/tags">tags</a></li> | |
87 | <li><a href="/bookmarks">bookmarks</a></li> |
|
87 | <li><a href="/bookmarks">bookmarks</a></li> | |
88 | <li><a href="/branches">branches</a></li> |
|
88 | <li><a href="/branches">branches</a></li> | |
89 | </ul> |
|
89 | </ul> | |
90 | <ul> |
|
90 | <ul> | |
91 | <li><a href="/rev/tip">changeset</a></li> |
|
91 | <li><a href="/rev/tip">changeset</a></li> | |
92 | <li><a href="/file/tip/">browse</a></li> |
|
92 | <li><a href="/file/tip/">browse</a></li> | |
93 | </ul> |
|
93 | </ul> | |
94 | <ul> |
|
94 | <ul> | |
95 | <li class="active">file</li> |
|
95 | <li class="active">file</li> | |
96 | <li><a href="/file/tip/primes.py">latest</a></li> |
|
96 | <li><a href="/file/tip/primes.py">latest</a></li> | |
97 | <li><a href="/diff/tip/primes.py">diff</a></li> |
|
97 | <li><a href="/diff/tip/primes.py">diff</a></li> | |
98 | <li><a href="/comparison/tip/primes.py">comparison</a></li> |
|
98 | <li><a href="/comparison/tip/primes.py">comparison</a></li> | |
99 | <li><a href="/annotate/tip/primes.py">annotate</a></li> |
|
99 | <li><a href="/annotate/tip/primes.py">annotate</a></li> | |
100 | <li><a href="/log/tip/primes.py">file log</a></li> |
|
100 | <li><a href="/log/tip/primes.py">file log</a></li> | |
101 | <li><a href="/raw-file/tip/primes.py">raw</a></li> |
|
101 | <li><a href="/raw-file/tip/primes.py">raw</a></li> | |
102 | </ul> |
|
102 | </ul> | |
103 | <ul> |
|
103 | <ul> | |
104 | <li><a href="/help">help</a></li> |
|
104 | <li><a href="/help">help</a></li> | |
105 | </ul> |
|
105 | </ul> | |
106 | </div> |
|
106 | </div> | |
107 |
|
107 | |||
108 | <div class="main"> |
|
108 | <div class="main"> | |
109 | <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2> |
|
109 | <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2> | |
110 | <h3> |
|
110 | <h3> | |
111 | view primes.py @ 0:<a href="/rev/06824edf55d0">06824edf55d0</a> |
|
111 | view primes.py @ 0:<a href="/rev/06824edf55d0">06824edf55d0</a> | |
112 | <span class="tag">tip</span> |
|
112 | <span class="tag">tip</span> | |
113 | </h3> |
|
113 | </h3> | |
114 |
|
114 | |||
115 | <form class="search" action="/log"> |
|
115 | <form class="search" action="/log"> | |
116 |
|
116 | |||
117 | <p><input name="rev" id="search1" type="text" size="30" /></p> |
|
117 | <p><input name="rev" id="search1" type="text" size="30" /></p> | |
118 | <div id="hint">Find changesets by keywords (author, files, the commit message), revision |
|
118 | <div id="hint">Find changesets by keywords (author, files, the commit message), revision | |
119 | number or hash, or <a href="/help/revsets">revset expression</a>.</div> |
|
119 | number or hash, or <a href="/help/revsets">revset expression</a>.</div> | |
120 | </form> |
|
120 | </form> | |
121 |
|
121 | |||
122 | <div class="description">a</div> |
|
122 | <div class="description">a</div> | |
123 |
|
123 | |||
124 | <table id="changesetEntry"> |
|
124 | <table id="changesetEntry"> | |
125 | <tr> |
|
125 | <tr> | |
126 | <th class="author">author</th> |
|
126 | <th class="author">author</th> | |
127 | <td class="author">test</td> |
|
127 | <td class="author">test</td> | |
128 | </tr> |
|
128 | </tr> | |
129 | <tr> |
|
129 | <tr> | |
130 | <th class="date">date</th> |
|
130 | <th class="date">date</th> | |
131 | <td class="date age">Thu, 01 Jan 1970 00:00:00 +0000</td> |
|
131 | <td class="date age">Thu, 01 Jan 1970 00:00:00 +0000</td> | |
132 | </tr> |
|
132 | </tr> | |
133 | <tr> |
|
133 | <tr> | |
134 | <th class="author">parents</th> |
|
134 | <th class="author">parents</th> | |
135 | <td class="author"></td> |
|
135 | <td class="author"></td> | |
136 | </tr> |
|
136 | </tr> | |
137 | <tr> |
|
137 | <tr> | |
138 | <th class="author">children</th> |
|
138 | <th class="author">children</th> | |
139 | <td class="author"></td> |
|
139 | <td class="author"></td> | |
140 | </tr> |
|
140 | </tr> | |
141 | </table> |
|
141 | </table> | |
142 |
|
142 | |||
143 | <div class="overflow"> |
|
143 | <div class="overflow"> | |
144 | <div class="sourcefirst linewraptoggle">line wrap: <a class="linewraplink" href="javascript:toggleLinewrap()">on</a></div> |
|
144 | <div class="sourcefirst linewraptoggle">line wrap: <a class="linewraplink" href="javascript:toggleLinewrap()">on</a></div> | |
145 | <div class="sourcefirst"> line source</div> |
|
145 | <div class="sourcefirst"> line source</div> | |
146 | <pre class="sourcelines stripes4 wrap bottomline"> |
|
146 | <pre class="sourcelines stripes4 wrap bottomline"> | |
147 | <span id="l1"><span class="c">#!/usr/bin/env python</span></span><a href="#l1"></a> |
|
147 | <span id="l1"><span class="c">#!/usr/bin/env python</span></span><a href="#l1"></a> | |
148 | <span id="l2"></span><a href="#l2"></a> |
|
148 | <span id="l2"></span><a href="#l2"></a> | |
149 | <span id="l3"><span class="sd">"""Fun with generators. Corresponding Haskell implementation:</span></span><a href="#l3"></a> |
|
149 | <span id="l3"><span class="sd">"""Fun with generators. Corresponding Haskell implementation:</span></span><a href="#l3"></a> | |
150 | <span id="l4"></span><a href="#l4"></a> |
|
150 | <span id="l4"></span><a href="#l4"></a> | |
151 | <span id="l5"><span class="sd">primes = 2 : sieve [3, 5..]</span></span><a href="#l5"></a> |
|
151 | <span id="l5"><span class="sd">primes = 2 : sieve [3, 5..]</span></span><a href="#l5"></a> | |
152 | <span id="l6"><span class="sd"> where sieve (p:ns) = p : sieve [n | n <- ns, mod n p /= 0]</span></span><a href="#l6"></a> |
|
152 | <span id="l6"><span class="sd"> where sieve (p:ns) = p : sieve [n | n <- ns, mod n p /= 0]</span></span><a href="#l6"></a> | |
153 | <span id="l7"><span class="sd">"""</span></span><a href="#l7"></a> |
|
153 | <span id="l7"><span class="sd">"""</span></span><a href="#l7"></a> | |
154 | <span id="l8"></span><a href="#l8"></a> |
|
154 | <span id="l8"></span><a href="#l8"></a> | |
155 | <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> |
|
155 | <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> | |
156 | <span id="l10"></span><a href="#l10"></a> |
|
156 | <span id="l10"></span><a href="#l10"></a> | |
157 | <span id="l11"><span class="kn">def</span> <span class="nf">primes</span><span class="p">():</span></span><a href="#l11"></a> |
|
157 | <span id="l11"><span class="kn">def</span> <span class="nf">primes</span><span class="p">():</span></span><a href="#l11"></a> | |
158 | <span id="l12"> <span class="sd">"""Generate all primes."""</span></span><a href="#l12"></a> |
|
158 | <span id="l12"> <span class="sd">"""Generate all primes."""</span></span><a href="#l12"></a> | |
159 | <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> |
|
159 | <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> | |
160 | <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> |
|
160 | <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> | |
161 | <span id="l15"> <span class="c"># It is important to yield *here* in order to stop the</span></span><a href="#l15"></a> |
|
161 | <span id="l15"> <span class="c"># It is important to yield *here* in order to stop the</span></span><a href="#l15"></a> | |
162 | <span id="l16"> <span class="c"># infinite recursion.</span></span><a href="#l16"></a> |
|
162 | <span id="l16"> <span class="c"># infinite recursion.</span></span><a href="#l16"></a> | |
163 | <span id="l17"> <span class="kn">yield</span> <span class="n">p</span></span><a href="#l17"></a> |
|
163 | <span id="l17"> <span class="kn">yield</span> <span class="n">p</span></span><a href="#l17"></a> | |
164 | <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> |
|
164 | <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> | |
165 | <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> |
|
165 | <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> | |
166 | <span id="l20"> <span class="kn">yield</span> <span class="n">n</span></span><a href="#l20"></a> |
|
166 | <span id="l20"> <span class="kn">yield</span> <span class="n">n</span></span><a href="#l20"></a> | |
167 | <span id="l21"></span><a href="#l21"></a> |
|
167 | <span id="l21"></span><a href="#l21"></a> | |
168 | <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> |
|
168 | <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> | |
169 | <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"><</span> <span class="mi">3</span><span class="p">,</span> <span class="n">odds</span><span class="p">)))</span></span><a href="#l23"></a> |
|
169 | <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"><</span> <span class="mi">3</span><span class="p">,</span> <span class="n">odds</span><span class="p">)))</span></span><a href="#l23"></a> | |
170 | <span id="l24"></span><a href="#l24"></a> |
|
170 | <span id="l24"></span><a href="#l24"></a> | |
171 | <span id="l25"><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="#l25"></a> |
|
171 | <span id="l25"><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="#l25"></a> | |
172 | <span id="l26"> <span class="kn">import</span> <span class="nn">sys</span></span><a href="#l26"></a> |
|
172 | <span id="l26"> <span class="kn">import</span> <span class="nn">sys</span></span><a href="#l26"></a> | |
173 | <span id="l27"> <span class="kn">try</span><span class="p">:</span></span><a href="#l27"></a> |
|
173 | <span id="l27"> <span class="kn">try</span><span class="p">:</span></span><a href="#l27"></a> | |
174 | <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> |
|
174 | <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> | |
175 | <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> |
|
175 | <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> | |
176 | <span id="l30"> <span class="n">n</span> <span class="o">=</span> <span class="mi">10</span></span><a href="#l30"></a> |
|
176 | <span id="l30"> <span class="n">n</span> <span class="o">=</span> <span class="mi">10</span></span><a href="#l30"></a> | |
177 | <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> |
|
177 | <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> | |
178 | <span id="l32"> <span class="kn">print</span> <span class="s">"The first </span><span class="si">%d</span><span class="s"> primes: </span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="nb">list</span><span class="p">(</span><span class="n">islice</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">n</span><span class="p">)))</span></span><a href="#l32"></a> |
|
178 | <span id="l32"> <span class="kn">print</span> <span class="s">"The first </span><span class="si">%d</span><span class="s"> primes: </span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="nb">list</span><span class="p">(</span><span class="n">islice</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">n</span><span class="p">)))</span></span><a href="#l32"></a> | |
179 | <span id="l33"></span><a href="#l33"></a></pre> |
|
179 | <span id="l33"></span><a href="#l33"></a></pre> | |
180 | </div> |
|
180 | </div> | |
181 | </div> |
|
181 | </div> | |
182 | </div> |
|
182 | </div> | |
183 |
|
183 | |||
184 | <script type="text/javascript">process_dates()</script> |
|
184 | <script type="text/javascript">process_dates()</script> | |
185 |
|
185 | |||
186 |
|
186 | |||
187 | </body> |
|
187 | </body> | |
188 | </html> |
|
188 | </html> | |
189 |
|
189 | |||
190 |
|
190 | |||
191 | hgweb fileannotate, html |
|
191 | hgweb fileannotate, html | |
192 |
|
192 | |||
193 | $ (get-with-headers.py localhost:$HGPORT 'annotate/tip/primes.py') \ |
|
193 | $ (get-with-headers.py localhost:$HGPORT 'annotate/tip/primes.py') \ | |
194 |
> | sed "s/class=\"k\"/class=\"kn\"/g" | sed "s/class=\"m |
|
194 | > | sed "s/class=\"k\"/class=\"kn\"/g" | sed "s/class=\"mf\"/class=\"mi\"/g" | |
195 | 200 Script output follows |
|
195 | 200 Script output follows | |
196 |
|
196 | |||
197 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
|
197 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> | |
198 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US"> |
|
198 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US"> | |
199 | <head> |
|
199 | <head> | |
200 | <link rel="icon" href="/static/hgicon.png" type="image/png" /> |
|
200 | <link rel="icon" href="/static/hgicon.png" type="image/png" /> | |
201 | <meta name="robots" content="index, nofollow" /> |
|
201 | <meta name="robots" content="index, nofollow" /> | |
202 | <link rel="stylesheet" href="/static/style-paper.css" type="text/css" /> |
|
202 | <link rel="stylesheet" href="/static/style-paper.css" type="text/css" /> | |
203 | <script type="text/javascript" src="/static/mercurial.js"></script> |
|
203 | <script type="text/javascript" src="/static/mercurial.js"></script> | |
204 |
|
204 | |||
205 | <link rel="stylesheet" href="/highlightcss" type="text/css" /> |
|
205 | <link rel="stylesheet" href="/highlightcss" type="text/css" /> | |
206 | <title>test: primes.py annotate</title> |
|
206 | <title>test: primes.py annotate</title> | |
207 | </head> |
|
207 | </head> | |
208 | <body> |
|
208 | <body> | |
209 |
|
209 | |||
210 | <div class="container"> |
|
210 | <div class="container"> | |
211 | <div class="menu"> |
|
211 | <div class="menu"> | |
212 | <div class="logo"> |
|
212 | <div class="logo"> | |
213 | <a href="https://mercurial-scm.org/"> |
|
213 | <a href="https://mercurial-scm.org/"> | |
214 | <img src="/static/hglogo.png" alt="mercurial" /></a> |
|
214 | <img src="/static/hglogo.png" alt="mercurial" /></a> | |
215 | </div> |
|
215 | </div> | |
216 | <ul> |
|
216 | <ul> | |
217 | <li><a href="/shortlog/tip">log</a></li> |
|
217 | <li><a href="/shortlog/tip">log</a></li> | |
218 | <li><a href="/graph/tip">graph</a></li> |
|
218 | <li><a href="/graph/tip">graph</a></li> | |
219 | <li><a href="/tags">tags</a></li> |
|
219 | <li><a href="/tags">tags</a></li> | |
220 | <li><a href="/bookmarks">bookmarks</a></li> |
|
220 | <li><a href="/bookmarks">bookmarks</a></li> | |
221 | <li><a href="/branches">branches</a></li> |
|
221 | <li><a href="/branches">branches</a></li> | |
222 | </ul> |
|
222 | </ul> | |
223 |
|
223 | |||
224 | <ul> |
|
224 | <ul> | |
225 | <li><a href="/rev/tip">changeset</a></li> |
|
225 | <li><a href="/rev/tip">changeset</a></li> | |
226 | <li><a href="/file/tip/">browse</a></li> |
|
226 | <li><a href="/file/tip/">browse</a></li> | |
227 | </ul> |
|
227 | </ul> | |
228 | <ul> |
|
228 | <ul> | |
229 | <li><a href="/file/tip/primes.py">file</a></li> |
|
229 | <li><a href="/file/tip/primes.py">file</a></li> | |
230 | <li><a href="/file/tip/primes.py">latest</a></li> |
|
230 | <li><a href="/file/tip/primes.py">latest</a></li> | |
231 | <li><a href="/diff/tip/primes.py">diff</a></li> |
|
231 | <li><a href="/diff/tip/primes.py">diff</a></li> | |
232 | <li><a href="/comparison/tip/primes.py">comparison</a></li> |
|
232 | <li><a href="/comparison/tip/primes.py">comparison</a></li> | |
233 | <li class="active">annotate</li> |
|
233 | <li class="active">annotate</li> | |
234 | <li><a href="/log/tip/primes.py">file log</a></li> |
|
234 | <li><a href="/log/tip/primes.py">file log</a></li> | |
235 | <li><a href="/raw-annotate/tip/primes.py">raw</a></li> |
|
235 | <li><a href="/raw-annotate/tip/primes.py">raw</a></li> | |
236 | </ul> |
|
236 | </ul> | |
237 | <ul> |
|
237 | <ul> | |
238 | <li><a href="/help">help</a></li> |
|
238 | <li><a href="/help">help</a></li> | |
239 | </ul> |
|
239 | </ul> | |
240 | </div> |
|
240 | </div> | |
241 |
|
241 | |||
242 | <div class="main"> |
|
242 | <div class="main"> | |
243 | <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2> |
|
243 | <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2> | |
244 | <h3> |
|
244 | <h3> | |
245 | annotate primes.py @ 0:<a href="/rev/06824edf55d0">06824edf55d0</a> |
|
245 | annotate primes.py @ 0:<a href="/rev/06824edf55d0">06824edf55d0</a> | |
246 | <span class="tag">tip</span> |
|
246 | <span class="tag">tip</span> | |
247 | </h3> |
|
247 | </h3> | |
248 |
|
248 | |||
249 | <form class="search" action="/log"> |
|
249 | <form class="search" action="/log"> | |
250 |
|
250 | |||
251 | <p><input name="rev" id="search1" type="text" size="30" /></p> |
|
251 | <p><input name="rev" id="search1" type="text" size="30" /></p> | |
252 | <div id="hint">Find changesets by keywords (author, files, the commit message), revision |
|
252 | <div id="hint">Find changesets by keywords (author, files, the commit message), revision | |
253 | number or hash, or <a href="/help/revsets">revset expression</a>.</div> |
|
253 | number or hash, or <a href="/help/revsets">revset expression</a>.</div> | |
254 | </form> |
|
254 | </form> | |
255 |
|
255 | |||
256 | <div class="description">a</div> |
|
256 | <div class="description">a</div> | |
257 |
|
257 | |||
258 | <table id="changesetEntry"> |
|
258 | <table id="changesetEntry"> | |
259 | <tr> |
|
259 | <tr> | |
260 | <th class="author">author</th> |
|
260 | <th class="author">author</th> | |
261 | <td class="author">test</td> |
|
261 | <td class="author">test</td> | |
262 | </tr> |
|
262 | </tr> | |
263 | <tr> |
|
263 | <tr> | |
264 | <th class="date">date</th> |
|
264 | <th class="date">date</th> | |
265 | <td class="date age">Thu, 01 Jan 1970 00:00:00 +0000</td> |
|
265 | <td class="date age">Thu, 01 Jan 1970 00:00:00 +0000</td> | |
266 | </tr> |
|
266 | </tr> | |
267 | <tr> |
|
267 | <tr> | |
268 | <th class="author">parents</th> |
|
268 | <th class="author">parents</th> | |
269 | <td class="author"></td> |
|
269 | <td class="author"></td> | |
270 | </tr> |
|
270 | </tr> | |
271 | <tr> |
|
271 | <tr> | |
272 | <th class="author">children</th> |
|
272 | <th class="author">children</th> | |
273 | <td class="author"></td> |
|
273 | <td class="author"></td> | |
274 | </tr> |
|
274 | </tr> | |
275 | </table> |
|
275 | </table> | |
276 |
|
276 | |||
277 | <div class="overflow"> |
|
277 | <div class="overflow"> | |
278 | <table class="bigtable"> |
|
278 | <table class="bigtable"> | |
279 | <thead> |
|
279 | <thead> | |
280 | <tr> |
|
280 | <tr> | |
281 | <th class="annotate">rev</th> |
|
281 | <th class="annotate">rev</th> | |
282 | <th class="line"> line source</th> |
|
282 | <th class="line"> line source</th> | |
283 | </tr> |
|
283 | </tr> | |
284 | </thead> |
|
284 | </thead> | |
285 | <tbody class="stripes2"> |
|
285 | <tbody class="stripes2"> | |
286 |
|
286 | |||
287 | <tr id="l1"> |
|
287 | <tr id="l1"> | |
288 | <td class="annotate"> |
|
288 | <td class="annotate"> | |
289 | <a href="/annotate/06824edf55d0/primes.py#l1" |
|
289 | <a href="/annotate/06824edf55d0/primes.py#l1" | |
290 | title="06824edf55d0: a">test@0</a> |
|
290 | title="06824edf55d0: a">test@0</a> | |
291 | </td> |
|
291 | </td> | |
292 | <td class="source"><a href="#l1"> 1</a> <span class="c">#!/usr/bin/env python</span></td> |
|
292 | <td class="source"><a href="#l1"> 1</a> <span class="c">#!/usr/bin/env python</span></td> | |
293 | </tr> |
|
293 | </tr> | |
294 | <tr id="l2"> |
|
294 | <tr id="l2"> | |
295 | <td class="annotate"> |
|
295 | <td class="annotate"> | |
296 | <a href="/annotate/06824edf55d0/primes.py#l2" |
|
296 | <a href="/annotate/06824edf55d0/primes.py#l2" | |
297 | title="06824edf55d0: a">test@0</a> |
|
297 | title="06824edf55d0: a">test@0</a> | |
298 | </td> |
|
298 | </td> | |
299 | <td class="source"><a href="#l2"> 2</a> </td> |
|
299 | <td class="source"><a href="#l2"> 2</a> </td> | |
300 | </tr> |
|
300 | </tr> | |
301 | <tr id="l3"> |
|
301 | <tr id="l3"> | |
302 | <td class="annotate"> |
|
302 | <td class="annotate"> | |
303 | <a href="/annotate/06824edf55d0/primes.py#l3" |
|
303 | <a href="/annotate/06824edf55d0/primes.py#l3" | |
304 | title="06824edf55d0: a">test@0</a> |
|
304 | title="06824edf55d0: a">test@0</a> | |
305 | </td> |
|
305 | </td> | |
306 | <td class="source"><a href="#l3"> 3</a> <span class="sd">"""Fun with generators. Corresponding Haskell implementation:</span></td> |
|
306 | <td class="source"><a href="#l3"> 3</a> <span class="sd">"""Fun with generators. Corresponding Haskell implementation:</span></td> | |
307 | </tr> |
|
307 | </tr> | |
308 | <tr id="l4"> |
|
308 | <tr id="l4"> | |
309 | <td class="annotate"> |
|
309 | <td class="annotate"> | |
310 | <a href="/annotate/06824edf55d0/primes.py#l4" |
|
310 | <a href="/annotate/06824edf55d0/primes.py#l4" | |
311 | title="06824edf55d0: a">test@0</a> |
|
311 | title="06824edf55d0: a">test@0</a> | |
312 | </td> |
|
312 | </td> | |
313 | <td class="source"><a href="#l4"> 4</a> </td> |
|
313 | <td class="source"><a href="#l4"> 4</a> </td> | |
314 | </tr> |
|
314 | </tr> | |
315 | <tr id="l5"> |
|
315 | <tr id="l5"> | |
316 | <td class="annotate"> |
|
316 | <td class="annotate"> | |
317 | <a href="/annotate/06824edf55d0/primes.py#l5" |
|
317 | <a href="/annotate/06824edf55d0/primes.py#l5" | |
318 | title="06824edf55d0: a">test@0</a> |
|
318 | title="06824edf55d0: a">test@0</a> | |
319 | </td> |
|
319 | </td> | |
320 | <td class="source"><a href="#l5"> 5</a> <span class="sd">primes = 2 : sieve [3, 5..]</span></td> |
|
320 | <td class="source"><a href="#l5"> 5</a> <span class="sd">primes = 2 : sieve [3, 5..]</span></td> | |
321 | </tr> |
|
321 | </tr> | |
322 | <tr id="l6"> |
|
322 | <tr id="l6"> | |
323 | <td class="annotate"> |
|
323 | <td class="annotate"> | |
324 | <a href="/annotate/06824edf55d0/primes.py#l6" |
|
324 | <a href="/annotate/06824edf55d0/primes.py#l6" | |
325 | title="06824edf55d0: a">test@0</a> |
|
325 | title="06824edf55d0: a">test@0</a> | |
326 | </td> |
|
326 | </td> | |
327 | <td class="source"><a href="#l6"> 6</a> <span class="sd"> where sieve (p:ns) = p : sieve [n | n <- ns, mod n p /= 0]</span></td> |
|
327 | <td class="source"><a href="#l6"> 6</a> <span class="sd"> where sieve (p:ns) = p : sieve [n | n <- ns, mod n p /= 0]</span></td> | |
328 | </tr> |
|
328 | </tr> | |
329 | <tr id="l7"> |
|
329 | <tr id="l7"> | |
330 | <td class="annotate"> |
|
330 | <td class="annotate"> | |
331 | <a href="/annotate/06824edf55d0/primes.py#l7" |
|
331 | <a href="/annotate/06824edf55d0/primes.py#l7" | |
332 | title="06824edf55d0: a">test@0</a> |
|
332 | title="06824edf55d0: a">test@0</a> | |
333 | </td> |
|
333 | </td> | |
334 | <td class="source"><a href="#l7"> 7</a> <span class="sd">"""</span></td> |
|
334 | <td class="source"><a href="#l7"> 7</a> <span class="sd">"""</span></td> | |
335 | </tr> |
|
335 | </tr> | |
336 | <tr id="l8"> |
|
336 | <tr id="l8"> | |
337 | <td class="annotate"> |
|
337 | <td class="annotate"> | |
338 | <a href="/annotate/06824edf55d0/primes.py#l8" |
|
338 | <a href="/annotate/06824edf55d0/primes.py#l8" | |
339 | title="06824edf55d0: a">test@0</a> |
|
339 | title="06824edf55d0: a">test@0</a> | |
340 | </td> |
|
340 | </td> | |
341 | <td class="source"><a href="#l8"> 8</a> </td> |
|
341 | <td class="source"><a href="#l8"> 8</a> </td> | |
342 | </tr> |
|
342 | </tr> | |
343 | <tr id="l9"> |
|
343 | <tr id="l9"> | |
344 | <td class="annotate"> |
|
344 | <td class="annotate"> | |
345 | <a href="/annotate/06824edf55d0/primes.py#l9" |
|
345 | <a href="/annotate/06824edf55d0/primes.py#l9" | |
346 | title="06824edf55d0: a">test@0</a> |
|
346 | title="06824edf55d0: a">test@0</a> | |
347 | </td> |
|
347 | </td> | |
348 | <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> |
|
348 | <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> | |
349 | </tr> |
|
349 | </tr> | |
350 | <tr id="l10"> |
|
350 | <tr id="l10"> | |
351 | <td class="annotate"> |
|
351 | <td class="annotate"> | |
352 | <a href="/annotate/06824edf55d0/primes.py#l10" |
|
352 | <a href="/annotate/06824edf55d0/primes.py#l10" | |
353 | title="06824edf55d0: a">test@0</a> |
|
353 | title="06824edf55d0: a">test@0</a> | |
354 | </td> |
|
354 | </td> | |
355 | <td class="source"><a href="#l10"> 10</a> </td> |
|
355 | <td class="source"><a href="#l10"> 10</a> </td> | |
356 | </tr> |
|
356 | </tr> | |
357 | <tr id="l11"> |
|
357 | <tr id="l11"> | |
358 | <td class="annotate"> |
|
358 | <td class="annotate"> | |
359 | <a href="/annotate/06824edf55d0/primes.py#l11" |
|
359 | <a href="/annotate/06824edf55d0/primes.py#l11" | |
360 | title="06824edf55d0: a">test@0</a> |
|
360 | title="06824edf55d0: a">test@0</a> | |
361 | </td> |
|
361 | </td> | |
362 | <td class="source"><a href="#l11"> 11</a> <span class="kn">def</span> <span class="nf">primes</span><span class="p">():</span></td> |
|
362 | <td class="source"><a href="#l11"> 11</a> <span class="kn">def</span> <span class="nf">primes</span><span class="p">():</span></td> | |
363 | </tr> |
|
363 | </tr> | |
364 | <tr id="l12"> |
|
364 | <tr id="l12"> | |
365 | <td class="annotate"> |
|
365 | <td class="annotate"> | |
366 | <a href="/annotate/06824edf55d0/primes.py#l12" |
|
366 | <a href="/annotate/06824edf55d0/primes.py#l12" | |
367 | title="06824edf55d0: a">test@0</a> |
|
367 | title="06824edf55d0: a">test@0</a> | |
368 | </td> |
|
368 | </td> | |
369 | <td class="source"><a href="#l12"> 12</a> <span class="sd">"""Generate all primes."""</span></td> |
|
369 | <td class="source"><a href="#l12"> 12</a> <span class="sd">"""Generate all primes."""</span></td> | |
370 | </tr> |
|
370 | </tr> | |
371 | <tr id="l13"> |
|
371 | <tr id="l13"> | |
372 | <td class="annotate"> |
|
372 | <td class="annotate"> | |
373 | <a href="/annotate/06824edf55d0/primes.py#l13" |
|
373 | <a href="/annotate/06824edf55d0/primes.py#l13" | |
374 | title="06824edf55d0: a">test@0</a> |
|
374 | title="06824edf55d0: a">test@0</a> | |
375 | </td> |
|
375 | </td> | |
376 | <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> |
|
376 | <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> | |
377 | </tr> |
|
377 | </tr> | |
378 | <tr id="l14"> |
|
378 | <tr id="l14"> | |
379 | <td class="annotate"> |
|
379 | <td class="annotate"> | |
380 | <a href="/annotate/06824edf55d0/primes.py#l14" |
|
380 | <a href="/annotate/06824edf55d0/primes.py#l14" | |
381 | title="06824edf55d0: a">test@0</a> |
|
381 | title="06824edf55d0: a">test@0</a> | |
382 | </td> |
|
382 | </td> | |
383 | <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> |
|
383 | <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> | |
384 | </tr> |
|
384 | </tr> | |
385 | <tr id="l15"> |
|
385 | <tr id="l15"> | |
386 | <td class="annotate"> |
|
386 | <td class="annotate"> | |
387 | <a href="/annotate/06824edf55d0/primes.py#l15" |
|
387 | <a href="/annotate/06824edf55d0/primes.py#l15" | |
388 | title="06824edf55d0: a">test@0</a> |
|
388 | title="06824edf55d0: a">test@0</a> | |
389 | </td> |
|
389 | </td> | |
390 | <td class="source"><a href="#l15"> 15</a> <span class="c"># It is important to yield *here* in order to stop the</span></td> |
|
390 | <td class="source"><a href="#l15"> 15</a> <span class="c"># It is important to yield *here* in order to stop the</span></td> | |
391 | </tr> |
|
391 | </tr> | |
392 | <tr id="l16"> |
|
392 | <tr id="l16"> | |
393 | <td class="annotate"> |
|
393 | <td class="annotate"> | |
394 | <a href="/annotate/06824edf55d0/primes.py#l16" |
|
394 | <a href="/annotate/06824edf55d0/primes.py#l16" | |
395 | title="06824edf55d0: a">test@0</a> |
|
395 | title="06824edf55d0: a">test@0</a> | |
396 | </td> |
|
396 | </td> | |
397 | <td class="source"><a href="#l16"> 16</a> <span class="c"># infinite recursion.</span></td> |
|
397 | <td class="source"><a href="#l16"> 16</a> <span class="c"># infinite recursion.</span></td> | |
398 | </tr> |
|
398 | </tr> | |
399 | <tr id="l17"> |
|
399 | <tr id="l17"> | |
400 | <td class="annotate"> |
|
400 | <td class="annotate"> | |
401 | <a href="/annotate/06824edf55d0/primes.py#l17" |
|
401 | <a href="/annotate/06824edf55d0/primes.py#l17" | |
402 | title="06824edf55d0: a">test@0</a> |
|
402 | title="06824edf55d0: a">test@0</a> | |
403 | </td> |
|
403 | </td> | |
404 | <td class="source"><a href="#l17"> 17</a> <span class="kn">yield</span> <span class="n">p</span></td> |
|
404 | <td class="source"><a href="#l17"> 17</a> <span class="kn">yield</span> <span class="n">p</span></td> | |
405 | </tr> |
|
405 | </tr> | |
406 | <tr id="l18"> |
|
406 | <tr id="l18"> | |
407 | <td class="annotate"> |
|
407 | <td class="annotate"> | |
408 | <a href="/annotate/06824edf55d0/primes.py#l18" |
|
408 | <a href="/annotate/06824edf55d0/primes.py#l18" | |
409 | title="06824edf55d0: a">test@0</a> |
|
409 | title="06824edf55d0: a">test@0</a> | |
410 | </td> |
|
410 | </td> | |
411 |
<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="m |
|
411 | <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> | |
412 | </tr> |
|
412 | </tr> | |
413 | <tr id="l19"> |
|
413 | <tr id="l19"> | |
414 | <td class="annotate"> |
|
414 | <td class="annotate"> | |
415 | <a href="/annotate/06824edf55d0/primes.py#l19" |
|
415 | <a href="/annotate/06824edf55d0/primes.py#l19" | |
416 | title="06824edf55d0: a">test@0</a> |
|
416 | title="06824edf55d0: a">test@0</a> | |
417 | </td> |
|
417 | </td> | |
418 | <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> |
|
418 | <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> | |
419 | </tr> |
|
419 | </tr> | |
420 | <tr id="l20"> |
|
420 | <tr id="l20"> | |
421 | <td class="annotate"> |
|
421 | <td class="annotate"> | |
422 | <a href="/annotate/06824edf55d0/primes.py#l20" |
|
422 | <a href="/annotate/06824edf55d0/primes.py#l20" | |
423 | title="06824edf55d0: a">test@0</a> |
|
423 | title="06824edf55d0: a">test@0</a> | |
424 | </td> |
|
424 | </td> | |
425 | <td class="source"><a href="#l20"> 20</a> <span class="kn">yield</span> <span class="n">n</span></td> |
|
425 | <td class="source"><a href="#l20"> 20</a> <span class="kn">yield</span> <span class="n">n</span></td> | |
426 | </tr> |
|
426 | </tr> | |
427 | <tr id="l21"> |
|
427 | <tr id="l21"> | |
428 | <td class="annotate"> |
|
428 | <td class="annotate"> | |
429 | <a href="/annotate/06824edf55d0/primes.py#l21" |
|
429 | <a href="/annotate/06824edf55d0/primes.py#l21" | |
430 | title="06824edf55d0: a">test@0</a> |
|
430 | title="06824edf55d0: a">test@0</a> | |
431 | </td> |
|
431 | </td> | |
432 | <td class="source"><a href="#l21"> 21</a> </td> |
|
432 | <td class="source"><a href="#l21"> 21</a> </td> | |
433 | </tr> |
|
433 | </tr> | |
434 | <tr id="l22"> |
|
434 | <tr id="l22"> | |
435 | <td class="annotate"> |
|
435 | <td class="annotate"> | |
436 | <a href="/annotate/06824edf55d0/primes.py#l22" |
|
436 | <a href="/annotate/06824edf55d0/primes.py#l22" | |
437 | title="06824edf55d0: a">test@0</a> |
|
437 | title="06824edf55d0: a">test@0</a> | |
438 | </td> |
|
438 | </td> | |
439 |
<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="m |
|
439 | <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> | |
440 | </tr> |
|
440 | </tr> | |
441 | <tr id="l23"> |
|
441 | <tr id="l23"> | |
442 | <td class="annotate"> |
|
442 | <td class="annotate"> | |
443 | <a href="/annotate/06824edf55d0/primes.py#l23" |
|
443 | <a href="/annotate/06824edf55d0/primes.py#l23" | |
444 | title="06824edf55d0: a">test@0</a> |
|
444 | title="06824edf55d0: a">test@0</a> | |
445 | </td> |
|
445 | </td> | |
446 |
<td class="source"><a href="#l23"> 23</a> <span class="kn">return</span> <span class="n">chain</span><span class="p">([</span><span class="m |
|
446 | <td class="source"><a href="#l23"> 23</a> <span class="kn">return</span> <span class="n">chain</span><span class="p">([</span><span class="mi">2</span><span class="p">],</span> <span class="n">sieve</span><span class="p">(</span><span class="n">dropwhile</span><span class="p">(</span><span class="kn">lambda</span> <span class="n">n</span><span class="p">:</span> <span class="n">n</span> <span class="o"><</span> <span class="mi">3</span><span class="p">,</span> <span class="n">odds</span><span class="p">)))</span></td> | |
447 | </tr> |
|
447 | </tr> | |
448 | <tr id="l24"> |
|
448 | <tr id="l24"> | |
449 | <td class="annotate"> |
|
449 | <td class="annotate"> | |
450 | <a href="/annotate/06824edf55d0/primes.py#l24" |
|
450 | <a href="/annotate/06824edf55d0/primes.py#l24" | |
451 | title="06824edf55d0: a">test@0</a> |
|
451 | title="06824edf55d0: a">test@0</a> | |
452 | </td> |
|
452 | </td> | |
453 | <td class="source"><a href="#l24"> 24</a> </td> |
|
453 | <td class="source"><a href="#l24"> 24</a> </td> | |
454 | </tr> |
|
454 | </tr> | |
455 | <tr id="l25"> |
|
455 | <tr id="l25"> | |
456 | <td class="annotate"> |
|
456 | <td class="annotate"> | |
457 | <a href="/annotate/06824edf55d0/primes.py#l25" |
|
457 | <a href="/annotate/06824edf55d0/primes.py#l25" | |
458 | title="06824edf55d0: a">test@0</a> |
|
458 | title="06824edf55d0: a">test@0</a> | |
459 | </td> |
|
459 | </td> | |
460 | <td class="source"><a href="#l25"> 25</a> <span class="kn">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">"__main__"</span><span class="p">:</span></td> |
|
460 | <td class="source"><a href="#l25"> 25</a> <span class="kn">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">"__main__"</span><span class="p">:</span></td> | |
461 | </tr> |
|
461 | </tr> | |
462 | <tr id="l26"> |
|
462 | <tr id="l26"> | |
463 | <td class="annotate"> |
|
463 | <td class="annotate"> | |
464 | <a href="/annotate/06824edf55d0/primes.py#l26" |
|
464 | <a href="/annotate/06824edf55d0/primes.py#l26" | |
465 | title="06824edf55d0: a">test@0</a> |
|
465 | title="06824edf55d0: a">test@0</a> | |
466 | </td> |
|
466 | </td> | |
467 | <td class="source"><a href="#l26"> 26</a> <span class="kn">import</span> <span class="nn">sys</span></td> |
|
467 | <td class="source"><a href="#l26"> 26</a> <span class="kn">import</span> <span class="nn">sys</span></td> | |
468 | </tr> |
|
468 | </tr> | |
469 | <tr id="l27"> |
|
469 | <tr id="l27"> | |
470 | <td class="annotate"> |
|
470 | <td class="annotate"> | |
471 | <a href="/annotate/06824edf55d0/primes.py#l27" |
|
471 | <a href="/annotate/06824edf55d0/primes.py#l27" | |
472 | title="06824edf55d0: a">test@0</a> |
|
472 | title="06824edf55d0: a">test@0</a> | |
473 | </td> |
|
473 | </td> | |
474 | <td class="source"><a href="#l27"> 27</a> <span class="kn">try</span><span class="p">:</span></td> |
|
474 | <td class="source"><a href="#l27"> 27</a> <span class="kn">try</span><span class="p">:</span></td> | |
475 | </tr> |
|
475 | </tr> | |
476 | <tr id="l28"> |
|
476 | <tr id="l28"> | |
477 | <td class="annotate"> |
|
477 | <td class="annotate"> | |
478 | <a href="/annotate/06824edf55d0/primes.py#l28" |
|
478 | <a href="/annotate/06824edf55d0/primes.py#l28" | |
479 | title="06824edf55d0: a">test@0</a> |
|
479 | title="06824edf55d0: a">test@0</a> | |
480 | </td> |
|
480 | </td> | |
481 |
<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="m |
|
481 | <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> | |
482 | </tr> |
|
482 | </tr> | |
483 | <tr id="l29"> |
|
483 | <tr id="l29"> | |
484 | <td class="annotate"> |
|
484 | <td class="annotate"> | |
485 | <a href="/annotate/06824edf55d0/primes.py#l29" |
|
485 | <a href="/annotate/06824edf55d0/primes.py#l29" | |
486 | title="06824edf55d0: a">test@0</a> |
|
486 | title="06824edf55d0: a">test@0</a> | |
487 | </td> |
|
487 | </td> | |
488 | <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> |
|
488 | <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> | |
489 | </tr> |
|
489 | </tr> | |
490 | <tr id="l30"> |
|
490 | <tr id="l30"> | |
491 | <td class="annotate"> |
|
491 | <td class="annotate"> | |
492 | <a href="/annotate/06824edf55d0/primes.py#l30" |
|
492 | <a href="/annotate/06824edf55d0/primes.py#l30" | |
493 | title="06824edf55d0: a">test@0</a> |
|
493 | title="06824edf55d0: a">test@0</a> | |
494 | </td> |
|
494 | </td> | |
495 |
<td class="source"><a href="#l30"> 30</a> <span class="n">n</span> <span class="o">=</span> <span class="m |
|
495 | <td class="source"><a href="#l30"> 30</a> <span class="n">n</span> <span class="o">=</span> <span class="mi">10</span></td> | |
496 | </tr> |
|
496 | </tr> | |
497 | <tr id="l31"> |
|
497 | <tr id="l31"> | |
498 | <td class="annotate"> |
|
498 | <td class="annotate"> | |
499 | <a href="/annotate/06824edf55d0/primes.py#l31" |
|
499 | <a href="/annotate/06824edf55d0/primes.py#l31" | |
500 | title="06824edf55d0: a">test@0</a> |
|
500 | title="06824edf55d0: a">test@0</a> | |
501 | </td> |
|
501 | </td> | |
502 | <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> |
|
502 | <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> | |
503 | </tr> |
|
503 | </tr> | |
504 | <tr id="l32"> |
|
504 | <tr id="l32"> | |
505 | <td class="annotate"> |
|
505 | <td class="annotate"> | |
506 | <a href="/annotate/06824edf55d0/primes.py#l32" |
|
506 | <a href="/annotate/06824edf55d0/primes.py#l32" | |
507 | title="06824edf55d0: a">test@0</a> |
|
507 | title="06824edf55d0: a">test@0</a> | |
508 | </td> |
|
508 | </td> | |
509 | <td class="source"><a href="#l32"> 32</a> <span class="kn">print</span> <span class="s">"The first </span><span class="si">%d</span><span class="s"> primes: </span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="nb">list</span><span class="p">(</span><span class="n">islice</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">n</span><span class="p">)))</span></td> |
|
509 | <td class="source"><a href="#l32"> 32</a> <span class="kn">print</span> <span class="s">"The first </span><span class="si">%d</span><span class="s"> primes: </span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="nb">list</span><span class="p">(</span><span class="n">islice</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">n</span><span class="p">)))</span></td> | |
510 | </tr> |
|
510 | </tr> | |
511 | <tr id="l33"> |
|
511 | <tr id="l33"> | |
512 | <td class="annotate"> |
|
512 | <td class="annotate"> | |
513 | <a href="/annotate/06824edf55d0/primes.py#l33" |
|
513 | <a href="/annotate/06824edf55d0/primes.py#l33" | |
514 | title="06824edf55d0: a">test@0</a> |
|
514 | title="06824edf55d0: a">test@0</a> | |
515 | </td> |
|
515 | </td> | |
516 | <td class="source"><a href="#l33"> 33</a> </td> |
|
516 | <td class="source"><a href="#l33"> 33</a> </td> | |
517 | </tr> |
|
517 | </tr> | |
518 | </tbody> |
|
518 | </tbody> | |
519 | </table> |
|
519 | </table> | |
520 | </div> |
|
520 | </div> | |
521 | </div> |
|
521 | </div> | |
522 | </div> |
|
522 | </div> | |
523 |
|
523 | |||
524 | <script type="text/javascript">process_dates()</script> |
|
524 | <script type="text/javascript">process_dates()</script> | |
525 |
|
525 | |||
526 |
|
526 | |||
527 | </body> |
|
527 | </body> | |
528 | </html> |
|
528 | </html> | |
529 |
|
529 | |||
530 |
|
530 | |||
531 | hgweb fileannotate, raw |
|
531 | hgweb fileannotate, raw | |
532 |
|
532 | |||
533 | $ (get-with-headers.py localhost:$HGPORT 'annotate/tip/primes.py?style=raw') \ |
|
533 | $ (get-with-headers.py localhost:$HGPORT 'annotate/tip/primes.py?style=raw') \ | |
534 | > | sed "s/test@//" > a |
|
534 | > | sed "s/test@//" > a | |
535 | $ echo "200 Script output follows" > b |
|
535 | $ echo "200 Script output follows" > b | |
536 | $ echo "" >> b |
|
536 | $ echo "" >> b | |
537 | $ echo "" >> b |
|
537 | $ echo "" >> b | |
538 | $ hg annotate "primes.py" >> b |
|
538 | $ hg annotate "primes.py" >> b | |
539 | $ echo "" >> b |
|
539 | $ echo "" >> b | |
540 | $ echo "" >> b |
|
540 | $ echo "" >> b | |
541 | $ echo "" >> b |
|
541 | $ echo "" >> b | |
542 | $ echo "" >> b |
|
542 | $ echo "" >> b | |
543 | $ cmp b a || diff -u b a |
|
543 | $ cmp b a || diff -u b a | |
544 |
|
544 | |||
545 | hgweb filerevision, raw |
|
545 | hgweb filerevision, raw | |
546 |
|
546 | |||
547 | $ (get-with-headers.py localhost:$HGPORT 'file/tip/primes.py?style=raw') \ |
|
547 | $ (get-with-headers.py localhost:$HGPORT 'file/tip/primes.py?style=raw') \ | |
548 | > > a |
|
548 | > > a | |
549 | $ echo "200 Script output follows" > b |
|
549 | $ echo "200 Script output follows" > b | |
550 | $ echo "" >> b |
|
550 | $ echo "" >> b | |
551 | $ hg cat primes.py >> b |
|
551 | $ hg cat primes.py >> b | |
552 | $ cmp b a || diff -u b a |
|
552 | $ cmp b a || diff -u b a | |
553 |
|
553 | |||
554 | hgweb highlightcss friendly |
|
554 | hgweb highlightcss friendly | |
555 |
|
555 | |||
556 | $ get-with-headers.py localhost:$HGPORT 'highlightcss' > out |
|
556 | $ get-with-headers.py localhost:$HGPORT 'highlightcss' > out | |
557 | $ head -n 4 out |
|
557 | $ head -n 4 out | |
558 | 200 Script output follows |
|
558 | 200 Script output follows | |
559 |
|
559 | |||
560 | /* pygments_style = friendly */ |
|
560 | /* pygments_style = friendly */ | |
561 |
|
561 | |||
562 | $ rm out |
|
562 | $ rm out | |
563 |
|
563 | |||
564 | errors encountered |
|
564 | errors encountered | |
565 |
|
565 | |||
566 | $ cat errors.log |
|
566 | $ cat errors.log | |
567 | $ killdaemons.py |
|
567 | $ killdaemons.py | |
568 |
|
568 | |||
569 | Change the pygments style |
|
569 | Change the pygments style | |
570 |
|
570 | |||
571 | $ cat > .hg/hgrc <<EOF |
|
571 | $ cat > .hg/hgrc <<EOF | |
572 | > [web] |
|
572 | > [web] | |
573 | > pygments_style = fruity |
|
573 | > pygments_style = fruity | |
574 | > EOF |
|
574 | > EOF | |
575 |
|
575 | |||
576 | hg serve again |
|
576 | hg serve again | |
577 |
|
577 | |||
578 | $ hg serve -p $HGPORT -d -n test --pid-file=hg.pid -A access.log -E errors.log |
|
578 | $ hg serve -p $HGPORT -d -n test --pid-file=hg.pid -A access.log -E errors.log | |
579 | $ cat hg.pid >> $DAEMON_PIDS |
|
579 | $ cat hg.pid >> $DAEMON_PIDS | |
580 |
|
580 | |||
581 | hgweb highlightcss fruity |
|
581 | hgweb highlightcss fruity | |
582 |
|
582 | |||
583 | $ get-with-headers.py localhost:$HGPORT 'highlightcss' > out |
|
583 | $ get-with-headers.py localhost:$HGPORT 'highlightcss' > out | |
584 | $ head -n 4 out |
|
584 | $ head -n 4 out | |
585 | 200 Script output follows |
|
585 | 200 Script output follows | |
586 |
|
586 | |||
587 | /* pygments_style = fruity */ |
|
587 | /* pygments_style = fruity */ | |
588 |
|
588 | |||
589 | $ rm out |
|
589 | $ rm out | |
590 |
|
590 | |||
591 | errors encountered |
|
591 | errors encountered | |
592 |
|
592 | |||
593 | $ cat errors.log |
|
593 | $ cat errors.log | |
594 | $ killdaemons.py |
|
594 | $ killdaemons.py | |
595 |
|
595 | |||
596 | only highlight C source files |
|
596 | only highlight C source files | |
597 |
|
597 | |||
598 | $ cat > .hg/hgrc <<EOF |
|
598 | $ cat > .hg/hgrc <<EOF | |
599 | > [web] |
|
599 | > [web] | |
600 | > highlightfiles = **.c |
|
600 | > highlightfiles = **.c | |
601 | > EOF |
|
601 | > EOF | |
602 |
|
602 | |||
603 | hg serve again |
|
603 | hg serve again | |
604 |
|
604 | |||
605 | $ hg serve -p $HGPORT -d -n test --pid-file=hg.pid -A access.log -E errors.log |
|
605 | $ hg serve -p $HGPORT -d -n test --pid-file=hg.pid -A access.log -E errors.log | |
606 | $ cat hg.pid >> $DAEMON_PIDS |
|
606 | $ cat hg.pid >> $DAEMON_PIDS | |
607 |
|
607 | |||
608 | test that fileset in highlightfiles works and primes.py is not highlighted |
|
608 | test that fileset in highlightfiles works and primes.py is not highlighted | |
609 |
|
609 | |||
610 | $ get-with-headers.py localhost:$HGPORT 'file/tip/primes.py' | grep 'id="l11"' |
|
610 | $ get-with-headers.py localhost:$HGPORT 'file/tip/primes.py' | grep 'id="l11"' | |
611 | <span id="l11">def primes():</span><a href="#l11"></a> |
|
611 | <span id="l11">def primes():</span><a href="#l11"></a> | |
612 |
|
612 | |||
613 | errors encountered |
|
613 | errors encountered | |
614 |
|
614 | |||
615 | $ cat errors.log |
|
615 | $ cat errors.log | |
616 | $ cd .. |
|
616 | $ cd .. | |
617 | $ hg init eucjp |
|
617 | $ hg init eucjp | |
618 | $ cd eucjp |
|
618 | $ cd eucjp | |
619 | $ $PYTHON -c 'print("\265\376")' >> eucjp.txt # Japanese kanji "Kyo" |
|
619 | $ $PYTHON -c 'print("\265\376")' >> eucjp.txt # Japanese kanji "Kyo" | |
620 | $ hg ci -Ama |
|
620 | $ hg ci -Ama | |
621 | adding eucjp.txt |
|
621 | adding eucjp.txt | |
622 | $ hgserveget () { |
|
622 | $ hgserveget () { | |
623 | > killdaemons.py |
|
623 | > killdaemons.py | |
624 | > echo % HGENCODING="$1" hg serve |
|
624 | > echo % HGENCODING="$1" hg serve | |
625 | > HGENCODING="$1" hg serve -p $HGPORT -d -n test --pid-file=hg.pid -E errors.log |
|
625 | > HGENCODING="$1" hg serve -p $HGPORT -d -n test --pid-file=hg.pid -E errors.log | |
626 | > cat hg.pid >> $DAEMON_PIDS |
|
626 | > cat hg.pid >> $DAEMON_PIDS | |
627 | > |
|
627 | > | |
628 | > echo % hgweb filerevision, html |
|
628 | > echo % hgweb filerevision, html | |
629 | > get-with-headers.py localhost:$HGPORT "file/tip/$2" \ |
|
629 | > get-with-headers.py localhost:$HGPORT "file/tip/$2" \ | |
630 | > | grep '<div class="parity0 source">' |
|
630 | > | grep '<div class="parity0 source">' | |
631 | > echo % errors encountered |
|
631 | > echo % errors encountered | |
632 | > cat errors.log |
|
632 | > cat errors.log | |
633 | > } |
|
633 | > } | |
634 | $ hgserveget euc-jp eucjp.txt |
|
634 | $ hgserveget euc-jp eucjp.txt | |
635 | % HGENCODING=euc-jp hg serve |
|
635 | % HGENCODING=euc-jp hg serve | |
636 | % hgweb filerevision, html |
|
636 | % hgweb filerevision, html | |
637 | % errors encountered |
|
637 | % errors encountered | |
638 | $ hgserveget utf-8 eucjp.txt |
|
638 | $ hgserveget utf-8 eucjp.txt | |
639 | % HGENCODING=utf-8 hg serve |
|
639 | % HGENCODING=utf-8 hg serve | |
640 | % hgweb filerevision, html |
|
640 | % hgweb filerevision, html | |
641 | % errors encountered |
|
641 | % errors encountered | |
642 | $ hgserveget us-ascii eucjp.txt |
|
642 | $ hgserveget us-ascii eucjp.txt | |
643 | % HGENCODING=us-ascii hg serve |
|
643 | % HGENCODING=us-ascii hg serve | |
644 | % hgweb filerevision, html |
|
644 | % hgweb filerevision, html | |
645 | % errors encountered |
|
645 | % errors encountered | |
646 |
|
646 | |||
647 | We attempt to highlight unknown files by default |
|
647 | We attempt to highlight unknown files by default | |
648 |
|
648 | |||
649 | $ killdaemons.py |
|
649 | $ killdaemons.py | |
650 |
|
650 | |||
651 | $ cat > .hg/hgrc << EOF |
|
651 | $ cat > .hg/hgrc << EOF | |
652 | > [web] |
|
652 | > [web] | |
653 | > highlightfiles = ** |
|
653 | > highlightfiles = ** | |
654 | > EOF |
|
654 | > EOF | |
655 |
|
655 | |||
656 | $ cat > unknownfile << EOF |
|
656 | $ cat > unknownfile << EOF | |
657 | > #!/usr/bin/python |
|
657 | > #!/usr/bin/python | |
658 | > def foo(): |
|
658 | > def foo(): | |
659 | > pass |
|
659 | > pass | |
660 | > EOF |
|
660 | > EOF | |
661 |
|
661 | |||
662 | $ hg add unknownfile |
|
662 | $ hg add unknownfile | |
663 | $ hg commit -m unknown unknownfile |
|
663 | $ hg commit -m unknown unknownfile | |
664 |
|
664 | |||
665 | $ hg serve -p $HGPORT -d -n test --pid-file=hg.pid |
|
665 | $ hg serve -p $HGPORT -d -n test --pid-file=hg.pid | |
666 | $ cat hg.pid >> $DAEMON_PIDS |
|
666 | $ cat hg.pid >> $DAEMON_PIDS | |
667 |
|
667 | |||
668 | $ get-with-headers.py localhost:$HGPORT 'file/tip/unknownfile' | grep l2 |
|
668 | $ get-with-headers.py localhost:$HGPORT 'file/tip/unknownfile' | grep l2 | |
669 | <span id="l2"><span class="k">def</span> <span class="nf">foo</span><span class="p">():</span></span><a href="#l2"></a> |
|
669 | <span id="l2"><span class="k">def</span> <span class="nf">foo</span><span class="p">():</span></span><a href="#l2"></a> | |
670 |
|
670 | |||
671 | We can prevent Pygments from falling back to a non filename-based |
|
671 | We can prevent Pygments from falling back to a non filename-based | |
672 | detection mode |
|
672 | detection mode | |
673 |
|
673 | |||
674 | $ cat > .hg/hgrc << EOF |
|
674 | $ cat > .hg/hgrc << EOF | |
675 | > [web] |
|
675 | > [web] | |
676 | > highlightfiles = ** |
|
676 | > highlightfiles = ** | |
677 | > highlightonlymatchfilename = true |
|
677 | > highlightonlymatchfilename = true | |
678 | > EOF |
|
678 | > EOF | |
679 |
|
679 | |||
680 | $ killdaemons.py |
|
680 | $ killdaemons.py | |
681 | $ hg serve -p $HGPORT -d -n test --pid-file=hg.pid |
|
681 | $ hg serve -p $HGPORT -d -n test --pid-file=hg.pid | |
682 | $ cat hg.pid >> $DAEMON_PIDS |
|
682 | $ cat hg.pid >> $DAEMON_PIDS | |
683 | $ get-with-headers.py localhost:$HGPORT 'file/tip/unknownfile' | grep l2 |
|
683 | $ get-with-headers.py localhost:$HGPORT 'file/tip/unknownfile' | grep l2 | |
684 | <span id="l2">def foo():</span><a href="#l2"></a> |
|
684 | <span id="l2">def foo():</span><a href="#l2"></a> | |
685 |
|
685 | |||
686 | $ cd .. |
|
686 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now