##// END OF EJS Templates
hgweb: highlight line which is linked to at annotate view
Alexander Plavin -
r19463:f3393d45 default
parent child Browse files
Show More
@@ -1,245 +1,245 b''
1 default = 'shortlog'
1 default = 'shortlog'
2
2
3 mimetype = 'text/html; charset={encoding}'
3 mimetype = 'text/html; charset={encoding}'
4 header = header.tmpl
4 header = header.tmpl
5 footer = footer.tmpl
5 footer = footer.tmpl
6 search = search.tmpl
6 search = search.tmpl
7
7
8 changelog = shortlog.tmpl
8 changelog = shortlog.tmpl
9 shortlog = shortlog.tmpl
9 shortlog = shortlog.tmpl
10 shortlogentry = shortlogentry.tmpl
10 shortlogentry = shortlogentry.tmpl
11 graph = graph.tmpl
11 graph = graph.tmpl
12 help = help.tmpl
12 help = help.tmpl
13 helptopics = helptopics.tmpl
13 helptopics = helptopics.tmpl
14
14
15 helpentry = '
15 helpentry = '
16 <tr><td>
16 <tr><td>
17 <a href="{url|urlescape}help/{topic|escape}{sessionvars%urlparameter}">
17 <a href="{url|urlescape}help/{topic|escape}{sessionvars%urlparameter}">
18 {topic|escape}
18 {topic|escape}
19 </a>
19 </a>
20 </td><td>
20 </td><td>
21 {summary|escape}
21 {summary|escape}
22 </td></tr>'
22 </td></tr>'
23
23
24 naventry = '<a href="{url|urlescape}log/{node|short}{sessionvars%urlparameter}">{label|escape}</a> '
24 naventry = '<a href="{url|urlescape}log/{node|short}{sessionvars%urlparameter}">{label|escape}</a> '
25 navshortentry = '<a href="{url|urlescape}shortlog/{node|short}{sessionvars%urlparameter}">{label|escape}</a> '
25 navshortentry = '<a href="{url|urlescape}shortlog/{node|short}{sessionvars%urlparameter}">{label|escape}</a> '
26 navgraphentry = '<a href="{url|urlescape}graph/{node|short}{sessionvars%urlparameter}">{label|escape}</a> '
26 navgraphentry = '<a href="{url|urlescape}graph/{node|short}{sessionvars%urlparameter}">{label|escape}</a> '
27 filenaventry = '<a href="{url|urlescape}log/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{label|escape}</a> '
27 filenaventry = '<a href="{url|urlescape}log/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{label|escape}</a> '
28 filedifflink = '<a href="{url|urlescape}diff/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{file|escape}</a> '
28 filedifflink = '<a href="{url|urlescape}diff/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{file|escape}</a> '
29 filenodelink = '<a href="{url|urlescape}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{file|escape}</a> '
29 filenodelink = '<a href="{url|urlescape}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{file|escape}</a> '
30 filenolink = '{file|escape} '
30 filenolink = '{file|escape} '
31 fileellipses = '...'
31 fileellipses = '...'
32 diffstatlink = diffstat.tmpl
32 diffstatlink = diffstat.tmpl
33 diffstatnolink = diffstat.tmpl
33 diffstatnolink = diffstat.tmpl
34 changelogentry = shortlogentry.tmpl
34 changelogentry = shortlogentry.tmpl
35 searchentry = shortlogentry.tmpl
35 searchentry = shortlogentry.tmpl
36 changeset = changeset.tmpl
36 changeset = changeset.tmpl
37 manifest = manifest.tmpl
37 manifest = manifest.tmpl
38
38
39 nav = '{before%naventry} {after%naventry}'
39 nav = '{before%naventry} {after%naventry}'
40 navshort = '{before%navshortentry}{after%navshortentry}'
40 navshort = '{before%navshortentry}{after%navshortentry}'
41 navgraph = '{before%navgraphentry}{after%navgraphentry}'
41 navgraph = '{before%navgraphentry}{after%navgraphentry}'
42 filenav = '{before%filenaventry}{after%filenaventry}'
42 filenav = '{before%filenaventry}{after%filenaventry}'
43
43
44 direntry = '
44 direntry = '
45 <tr class="fileline">
45 <tr class="fileline">
46 <td class="name">
46 <td class="name">
47 <a href="{url|urlescape}file/{node|short}{path|urlescape}{sessionvars%urlparameter}">
47 <a href="{url|urlescape}file/{node|short}{path|urlescape}{sessionvars%urlparameter}">
48 <img src="{staticurl|urlescape}coal-folder.png" alt="dir."/> {basename|escape}/
48 <img src="{staticurl|urlescape}coal-folder.png" alt="dir."/> {basename|escape}/
49 </a>
49 </a>
50 <a href="{url|urlescape}file/{node|short}{path|urlescape}/{emptydirs|urlescape}{sessionvars%urlparameter}">
50 <a href="{url|urlescape}file/{node|short}{path|urlescape}/{emptydirs|urlescape}{sessionvars%urlparameter}">
51 {emptydirs|escape}
51 {emptydirs|escape}
52 </a>
52 </a>
53 </td>
53 </td>
54 <td class="size"></td>
54 <td class="size"></td>
55 <td class="permissions">drwxr-xr-x</td>
55 <td class="permissions">drwxr-xr-x</td>
56 </tr>'
56 </tr>'
57
57
58 fileentry = '
58 fileentry = '
59 <tr class="fileline">
59 <tr class="fileline">
60 <td class="filename">
60 <td class="filename">
61 <a href="{url|urlescape}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">
61 <a href="{url|urlescape}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">
62 <img src="{staticurl|urlescape}coal-file.png" alt="file"/> {basename|escape}
62 <img src="{staticurl|urlescape}coal-file.png" alt="file"/> {basename|escape}
63 </a>
63 </a>
64 </td>
64 </td>
65 <td class="size">{size}</td>
65 <td class="size">{size}</td>
66 <td class="permissions">{permissions|permissions}</td>
66 <td class="permissions">{permissions|permissions}</td>
67 </tr>'
67 </tr>'
68
68
69 filerevision = filerevision.tmpl
69 filerevision = filerevision.tmpl
70 fileannotate = fileannotate.tmpl
70 fileannotate = fileannotate.tmpl
71 filediff = filediff.tmpl
71 filediff = filediff.tmpl
72 filecomparison = filecomparison.tmpl
72 filecomparison = filecomparison.tmpl
73 filelog = filelog.tmpl
73 filelog = filelog.tmpl
74 fileline = '
74 fileline = '
75 <span id="{lineid}">{strip(line|escape, '\r\n')}</span><a href="#{lineid}"></a>'
75 <span id="{lineid}">{strip(line|escape, '\r\n')}</span><a href="#{lineid}"></a>'
76 filelogentry = filelogentry.tmpl
76 filelogentry = filelogentry.tmpl
77
77
78 annotateline = '
78 annotateline = '
79 <tr>
79 <tr id="{lineid}">
80 <td class="annotate">
80 <td class="annotate">
81 <a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#l{targetline}"
81 <a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#l{targetline}"
82 title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a>
82 title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a>
83 </td>
83 </td>
84 <td class="source"><a href="#{lineid}" id="{lineid}">{linenumber}</a> {line|escape}</td>
84 <td class="source"><a href="#{lineid}">{linenumber}</a> {line|escape}</td>
85 </tr>'
85 </tr>'
86
86
87 diffblock = '<div class="bottomline inc-lineno"><pre class="sourcelines wrap">{lines}</pre></div>'
87 diffblock = '<div class="bottomline inc-lineno"><pre class="sourcelines wrap">{lines}</pre></div>'
88 difflineplus = '
88 difflineplus = '
89 <span id="{lineid}" class="plusline">{strip(line|escape, '\r\n')}</span><a href="#{lineid}"></a>'
89 <span id="{lineid}" class="plusline">{strip(line|escape, '\r\n')}</span><a href="#{lineid}"></a>'
90 difflineminus = '
90 difflineminus = '
91 <span id="{lineid}" class="minusline">{strip(line|escape, '\r\n')}</span><a href="#{lineid}"></a>'
91 <span id="{lineid}" class="minusline">{strip(line|escape, '\r\n')}</span><a href="#{lineid}"></a>'
92 difflineat = '
92 difflineat = '
93 <span id="{lineid}" class="atline">{strip(line|escape, '\r\n')}</span><a href="#{lineid}"></a>'
93 <span id="{lineid}" class="atline">{strip(line|escape, '\r\n')}</span><a href="#{lineid}"></a>'
94 diffline = '
94 diffline = '
95 <span id="{lineid}">{strip(line|escape, '\r\n')}</span><a href="#{lineid}"></a>'
95 <span id="{lineid}">{strip(line|escape, '\r\n')}</span><a href="#{lineid}"></a>'
96
96
97 comparisonblock ='
97 comparisonblock ='
98 <tbody class="block">
98 <tbody class="block">
99 {lines}
99 {lines}
100 </tbody>'
100 </tbody>'
101 comparisonline = '
101 comparisonline = '
102 <tr id="{lineid}">
102 <tr id="{lineid}">
103 <td class="source {type}"><a href="#{lineid}">{leftlinenumber}</a> {leftline|escape}</td>
103 <td class="source {type}"><a href="#{lineid}">{leftlinenumber}</a> {leftline|escape}</td>
104 <td class="source {type}"><a href="#{lineid}">{rightlinenumber}</a> {rightline|escape}</td>
104 <td class="source {type}"><a href="#{lineid}">{rightlinenumber}</a> {rightline|escape}</td>
105 </tr>'
105 </tr>'
106
106
107 changelogparent = '
107 changelogparent = '
108 <tr>
108 <tr>
109 <th class="parent">parent {rev}:</th>
109 <th class="parent">parent {rev}:</th>
110 <td class="parent"><a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a></td>
110 <td class="parent"><a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a></td>
111 </tr>'
111 </tr>'
112
112
113 changesetparent = '<a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a> '
113 changesetparent = '<a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a> '
114
114
115 difffrom = '<a href="{url|urlescape}rev/{node|short}:{originalnode|short}{sessionvars%urlparameter}">{node|short}</a> '
115 difffrom = '<a href="{url|urlescape}rev/{node|short}:{originalnode|short}{sessionvars%urlparameter}">{node|short}</a> '
116
116
117 filerevparent = '<a href="{url|urlescape}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{rename%filerename}{node|short}</a> '
117 filerevparent = '<a href="{url|urlescape}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{rename%filerename}{node|short}</a> '
118 filerevchild = '<a href="{url|urlescape}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{node|short}</a> '
118 filerevchild = '<a href="{url|urlescape}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{node|short}</a> '
119
119
120 filerename = '{file|escape}@'
120 filerename = '{file|escape}@'
121 filelogrename = '
121 filelogrename = '
122 <span class="base">
122 <span class="base">
123 base
123 base
124 <a href="{url|urlescape}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">
124 <a href="{url|urlescape}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">
125 {file|escape}@{node|short}
125 {file|escape}@{node|short}
126 </a>
126 </a>
127 </span>'
127 </span>'
128 fileannotateparent = '
128 fileannotateparent = '
129 <tr>
129 <tr>
130 <td class="metatag">parent:</td>
130 <td class="metatag">parent:</td>
131 <td>
131 <td>
132 <a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}">
132 <a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}">
133 {rename%filerename}{node|short}
133 {rename%filerename}{node|short}
134 </a>
134 </a>
135 </td>
135 </td>
136 </tr>'
136 </tr>'
137 changesetchild = ' <a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a>'
137 changesetchild = ' <a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a>'
138 changelogchild = '
138 changelogchild = '
139 <tr>
139 <tr>
140 <th class="child">child</th>
140 <th class="child">child</th>
141 <td class="child">
141 <td class="child">
142 <a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">
142 <a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">
143 {node|short}
143 {node|short}
144 </a>
144 </a>
145 </td>
145 </td>
146 </tr>'
146 </tr>'
147 fileannotatechild = '
147 fileannotatechild = '
148 <tr>
148 <tr>
149 <td class="metatag">child:</td>
149 <td class="metatag">child:</td>
150 <td>
150 <td>
151 <a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}">
151 <a href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}">
152 {node|short}
152 {node|short}
153 </a>
153 </a>
154 </td>
154 </td>
155 </tr>'
155 </tr>'
156 tags = tags.tmpl
156 tags = tags.tmpl
157 tagentry = '
157 tagentry = '
158 <tr class="tagEntry">
158 <tr class="tagEntry">
159 <td>
159 <td>
160 <a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">
160 <a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">
161 {tag|escape}
161 {tag|escape}
162 </a>
162 </a>
163 </td>
163 </td>
164 <td class="node">
164 <td class="node">
165 {node|short}
165 {node|short}
166 </td>
166 </td>
167 </tr>'
167 </tr>'
168 bookmarks = bookmarks.tmpl
168 bookmarks = bookmarks.tmpl
169 bookmarkentry = '
169 bookmarkentry = '
170 <tr class="tagEntry">
170 <tr class="tagEntry">
171 <td>
171 <td>
172 <a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">
172 <a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">
173 {bookmark|escape}
173 {bookmark|escape}
174 </a>
174 </a>
175 </td>
175 </td>
176 <td class="node">
176 <td class="node">
177 {node|short}
177 {node|short}
178 </td>
178 </td>
179 </tr>'
179 </tr>'
180 branches = branches.tmpl
180 branches = branches.tmpl
181 branchentry = '
181 branchentry = '
182 <tr class="tagEntry">
182 <tr class="tagEntry">
183 <td>
183 <td>
184 <a href="{url|urlescape}shortlog/{node|short}{sessionvars%urlparameter}" class="{status}">
184 <a href="{url|urlescape}shortlog/{node|short}{sessionvars%urlparameter}" class="{status}">
185 {branch|escape}
185 {branch|escape}
186 </a>
186 </a>
187 </td>
187 </td>
188 <td class="node">
188 <td class="node">
189 {node|short}
189 {node|short}
190 </td>
190 </td>
191 </tr>'
191 </tr>'
192 changelogtag = '<span class="tag">{name|escape}</span> '
192 changelogtag = '<span class="tag">{name|escape}</span> '
193 changesettag = '<span class="tag">{tag|escape}</span> '
193 changesettag = '<span class="tag">{tag|escape}</span> '
194 changesetbookmark = '<span class="tag">{bookmark|escape}</span> '
194 changesetbookmark = '<span class="tag">{bookmark|escape}</span> '
195 changelogbranchhead = '<span class="branchhead">{name|escape}</span> '
195 changelogbranchhead = '<span class="branchhead">{name|escape}</span> '
196 changelogbranchname = '<span class="branchname">{name|escape}</span> '
196 changelogbranchname = '<span class="branchname">{name|escape}</span> '
197
197
198 filediffparent = '
198 filediffparent = '
199 <tr>
199 <tr>
200 <th class="parent">parent {rev}:</th>
200 <th class="parent">parent {rev}:</th>
201 <td class="parent"><a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a></td>
201 <td class="parent"><a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a></td>
202 </tr>'
202 </tr>'
203 filelogparent = '
203 filelogparent = '
204 <tr>
204 <tr>
205 <th>parent {rev}:</th>
205 <th>parent {rev}:</th>
206 <td><a href="{url|urlescape}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{node|short}</a></td>
206 <td><a href="{url|urlescape}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{node|short}</a></td>
207 </tr>'
207 </tr>'
208 filediffchild = '
208 filediffchild = '
209 <tr>
209 <tr>
210 <th class="child">child {rev}:</th>
210 <th class="child">child {rev}:</th>
211 <td class="child"><a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a>
211 <td class="child"><a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a>
212 </td>
212 </td>
213 </tr>'
213 </tr>'
214 filelogchild = '
214 filelogchild = '
215 <tr>
215 <tr>
216 <th>child {rev}:</th>
216 <th>child {rev}:</th>
217 <td><a href="{url|urlescape}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{node|short}</a></td>
217 <td><a href="{url|urlescape}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{node|short}</a></td>
218 </tr>'
218 </tr>'
219
219
220 indexentry = '
220 indexentry = '
221 <tr>
221 <tr>
222 <td><a href="{url|urlescape}{sessionvars%urlparameter}">{name|escape}</a></td>
222 <td><a href="{url|urlescape}{sessionvars%urlparameter}">{name|escape}</a></td>
223 <td>{description}</td>
223 <td>{description}</td>
224 <td>{contact|obfuscate}</td>
224 <td>{contact|obfuscate}</td>
225 <td class="age">{lastchange|rfc822date}</td>
225 <td class="age">{lastchange|rfc822date}</td>
226 <td class="indexlinks">{archives%indexarchiveentry}</td>
226 <td class="indexlinks">{archives%indexarchiveentry}</td>
227 <td>
227 <td>
228 {if(isdirectory, '',
228 {if(isdirectory, '',
229 '<a href="{url|urlescape}atom-log" title="subscribe to repository atom feed">
229 '<a href="{url|urlescape}atom-log" title="subscribe to repository atom feed">
230 <img class="atom-logo" src="{staticurl|urlescape}feed-icon-14x14.png" alt="subscribe to repository atom feed">
230 <img class="atom-logo" src="{staticurl|urlescape}feed-icon-14x14.png" alt="subscribe to repository atom feed">
231 </a>'
231 </a>'
232 )}
232 )}
233 </td>
233 </td>
234 </tr>\n'
234 </tr>\n'
235 indexarchiveentry = '<a href="{url|urlescape}archive/{node|short}{extension|urlescape}">&nbsp;&darr;{type|escape}</a>'
235 indexarchiveentry = '<a href="{url|urlescape}archive/{node|short}{extension|urlescape}">&nbsp;&darr;{type|escape}</a>'
236 index = index.tmpl
236 index = index.tmpl
237 archiveentry = '
237 archiveentry = '
238 <li>
238 <li>
239 <a href="{url|urlescape}archive/{node|short}{extension|urlescape}{ifeq(path,'/','',path|urlescape)}">{type|escape}</a>
239 <a href="{url|urlescape}archive/{node|short}{extension|urlescape}{ifeq(path,'/','',path|urlescape)}">{type|escape}</a>
240 </li>'
240 </li>'
241 notfound = notfound.tmpl
241 notfound = notfound.tmpl
242 error = error.tmpl
242 error = error.tmpl
243 urlparameter = '{separator}{name}={value|urlescape}'
243 urlparameter = '{separator}{name}={value|urlescape}'
244 hiddenformentry = '<input type="hidden" name="{name}" value="{value|escape}" />'
244 hiddenformentry = '<input type="hidden" name="{name}" value="{value|escape}" />'
245 breadcrumb = '&gt; <a href="{url|urlescape}">{name|escape}</a> '
245 breadcrumb = '&gt; <a href="{url|urlescape}">{name|escape}</a> '
@@ -1,609 +1,609 b''
1
1
2 $ "$TESTDIR/hghave" pygments serve || exit 80
2 $ "$TESTDIR/hghave" pygments serve || exit 80
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 > EOF
8 > EOF
9 $ hg init test
9 $ hg init test
10 $ cd test
10 $ cd test
11
11
12 create random Python file to exercise Pygments
12 create random Python file to exercise Pygments
13
13
14 $ cat <<EOF > primes.py
14 $ cat <<EOF > primes.py
15 > #!/usr/bin/env python
15 > #!/usr/bin/env python
16 >
16 >
17 > """Fun with generators. Corresponding Haskell implementation:
17 > """Fun with generators. Corresponding Haskell implementation:
18 >
18 >
19 > primes = 2 : sieve [3, 5..]
19 > primes = 2 : sieve [3, 5..]
20 > where sieve (p:ns) = p : sieve [n | n <- ns, mod n p /= 0]
20 > where sieve (p:ns) = p : sieve [n | n <- ns, mod n p /= 0]
21 > """
21 > """
22 >
22 >
23 > from itertools import dropwhile, ifilter, islice, count, chain
23 > from itertools import dropwhile, ifilter, islice, count, chain
24 >
24 >
25 > def primes():
25 > def primes():
26 > """Generate all primes."""
26 > """Generate all primes."""
27 > def sieve(ns):
27 > def sieve(ns):
28 > p = ns.next()
28 > p = ns.next()
29 > # It is important to yield *here* in order to stop the
29 > # It is important to yield *here* in order to stop the
30 > # infinite recursion.
30 > # infinite recursion.
31 > yield p
31 > yield p
32 > ns = ifilter(lambda n: n % p != 0, ns)
32 > ns = ifilter(lambda n: n % p != 0, ns)
33 > for n in sieve(ns):
33 > for n in sieve(ns):
34 > yield n
34 > yield n
35 >
35 >
36 > odds = ifilter(lambda i: i % 2 == 1, count())
36 > odds = ifilter(lambda i: i % 2 == 1, count())
37 > return chain([2], sieve(dropwhile(lambda n: n < 3, odds)))
37 > return chain([2], sieve(dropwhile(lambda n: n < 3, odds)))
38 >
38 >
39 > if __name__ == "__main__":
39 > if __name__ == "__main__":
40 > import sys
40 > import sys
41 > try:
41 > try:
42 > n = int(sys.argv[1])
42 > n = int(sys.argv[1])
43 > except (ValueError, IndexError):
43 > except (ValueError, IndexError):
44 > n = 10
44 > n = 10
45 > p = primes()
45 > p = primes()
46 > print "The first %d primes: %s" % (n, list(islice(p, n)))
46 > print "The first %d primes: %s" % (n, list(islice(p, n)))
47 > EOF
47 > EOF
48 $ hg ci -Ama
48 $ hg ci -Ama
49 adding primes.py
49 adding primes.py
50
50
51 hg serve
51 hg serve
52
52
53 $ hg serve -p $HGPORT -d -n test --pid-file=hg.pid -A access.log -E errors.log
53 $ hg serve -p $HGPORT -d -n test --pid-file=hg.pid -A access.log -E errors.log
54 $ cat hg.pid >> $DAEMON_PIDS
54 $ cat hg.pid >> $DAEMON_PIDS
55
55
56 hgweb filerevision, html
56 hgweb filerevision, html
57
57
58 $ ("$TESTDIR/get-with-headers.py" localhost:$HGPORT 'file/tip/primes.py') \
58 $ ("$TESTDIR/get-with-headers.py" localhost:$HGPORT 'file/tip/primes.py') \
59 > | sed "s/class=\"k\"/class=\"kn\"/g" | sed "s/class=\"mf\"/class=\"mi\"/g"
59 > | sed "s/class=\"k\"/class=\"kn\"/g" | sed "s/class=\"mf\"/class=\"mi\"/g"
60 200 Script output follows
60 200 Script output follows
61
61
62 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
62 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
63 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
63 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
64 <head>
64 <head>
65 <link rel="icon" href="/static/hgicon.png" type="image/png" />
65 <link rel="icon" href="/static/hgicon.png" type="image/png" />
66 <meta name="robots" content="index, nofollow" />
66 <meta name="robots" content="index, nofollow" />
67 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
67 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
68 <script type="text/javascript" src="/static/mercurial.js"></script>
68 <script type="text/javascript" src="/static/mercurial.js"></script>
69
69
70 <link rel="stylesheet" href="/highlightcss" type="text/css" />
70 <link rel="stylesheet" href="/highlightcss" type="text/css" />
71 <title>test: 853dcd4de2a6 primes.py</title>
71 <title>test: 853dcd4de2a6 primes.py</title>
72 </head>
72 </head>
73 <body>
73 <body>
74
74
75 <div class="container">
75 <div class="container">
76 <div class="menu">
76 <div class="menu">
77 <div class="logo">
77 <div class="logo">
78 <a href="http://mercurial.selenic.com/">
78 <a href="http://mercurial.selenic.com/">
79 <img src="/static/hglogo.png" alt="mercurial" /></a>
79 <img src="/static/hglogo.png" alt="mercurial" /></a>
80 </div>
80 </div>
81 <ul>
81 <ul>
82 <li><a href="/shortlog/853dcd4de2a6">log</a></li>
82 <li><a href="/shortlog/853dcd4de2a6">log</a></li>
83 <li><a href="/graph/853dcd4de2a6">graph</a></li>
83 <li><a href="/graph/853dcd4de2a6">graph</a></li>
84 <li><a href="/tags">tags</a></li>
84 <li><a href="/tags">tags</a></li>
85 <li><a href="/branches">branches</a></li>
85 <li><a href="/branches">branches</a></li>
86 </ul>
86 </ul>
87 <ul>
87 <ul>
88 <li><a href="/rev/853dcd4de2a6">changeset</a></li>
88 <li><a href="/rev/853dcd4de2a6">changeset</a></li>
89 <li><a href="/file/853dcd4de2a6/">browse</a></li>
89 <li><a href="/file/853dcd4de2a6/">browse</a></li>
90 </ul>
90 </ul>
91 <ul>
91 <ul>
92 <li class="active">file</li>
92 <li class="active">file</li>
93 <li><a href="/file/tip/primes.py">latest</a></li>
93 <li><a href="/file/tip/primes.py">latest</a></li>
94 <li><a href="/diff/853dcd4de2a6/primes.py">diff</a></li>
94 <li><a href="/diff/853dcd4de2a6/primes.py">diff</a></li>
95 <li><a href="/comparison/853dcd4de2a6/primes.py">comparison</a></li>
95 <li><a href="/comparison/853dcd4de2a6/primes.py">comparison</a></li>
96 <li><a href="/annotate/853dcd4de2a6/primes.py">annotate</a></li>
96 <li><a href="/annotate/853dcd4de2a6/primes.py">annotate</a></li>
97 <li><a href="/log/853dcd4de2a6/primes.py">file log</a></li>
97 <li><a href="/log/853dcd4de2a6/primes.py">file log</a></li>
98 <li><a href="/raw-file/853dcd4de2a6/primes.py">raw</a></li>
98 <li><a href="/raw-file/853dcd4de2a6/primes.py">raw</a></li>
99 </ul>
99 </ul>
100 <ul>
100 <ul>
101 <li><a href="/help">help</a></li>
101 <li><a href="/help">help</a></li>
102 </ul>
102 </ul>
103 </div>
103 </div>
104
104
105 <div class="main">
105 <div class="main">
106 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
106 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
107 <h3>view primes.py @ 0:853dcd4de2a6</h3>
107 <h3>view primes.py @ 0:853dcd4de2a6</h3>
108
108
109 <form class="search" action="/log">
109 <form class="search" action="/log">
110
110
111 <p><input name="rev" id="search1" type="text" size="30" /></p>
111 <p><input name="rev" id="search1" type="text" size="30" /></p>
112 <div id="hint">find changesets by author, revision,
112 <div id="hint">find changesets by author, revision,
113 files, or words in the commit message</div>
113 files, or words in the commit message</div>
114 </form>
114 </form>
115
115
116 <div class="description">a</div>
116 <div class="description">a</div>
117
117
118 <table id="changesetEntry">
118 <table id="changesetEntry">
119 <tr>
119 <tr>
120 <th class="author">author</th>
120 <th class="author">author</th>
121 <td class="author">&#116;&#101;&#115;&#116;</td>
121 <td class="author">&#116;&#101;&#115;&#116;</td>
122 </tr>
122 </tr>
123 <tr>
123 <tr>
124 <th class="date">date</th>
124 <th class="date">date</th>
125 <td class="date age">Thu, 01 Jan 1970 00:00:00 +0000</td>
125 <td class="date age">Thu, 01 Jan 1970 00:00:00 +0000</td>
126 </tr>
126 </tr>
127 <tr>
127 <tr>
128 <th class="author">parents</th>
128 <th class="author">parents</th>
129 <td class="author"></td>
129 <td class="author"></td>
130 </tr>
130 </tr>
131 <tr>
131 <tr>
132 <th class="author">children</th>
132 <th class="author">children</th>
133 <td class="author"></td>
133 <td class="author"></td>
134 </tr>
134 </tr>
135
135
136 </table>
136 </table>
137
137
138 <div class="overflow">
138 <div class="overflow">
139 <div class="sourcefirst linewraptoggle">line wrap: <a class="linewraplink" href="javascript:toggleLinewrap()">on</a></div>
139 <div class="sourcefirst linewraptoggle">line wrap: <a class="linewraplink" href="javascript:toggleLinewrap()">on</a></div>
140 <div class="sourcefirst"> line source</div>
140 <div class="sourcefirst"> line source</div>
141 <pre class="sourcelines stripes4 wrap">
141 <pre class="sourcelines stripes4 wrap">
142 <span id="l1"><span class="c">#!/usr/bin/env python</span></span><a href="#l1"></a>
142 <span id="l1"><span class="c">#!/usr/bin/env python</span></span><a href="#l1"></a>
143 <span id="l2"></span><a href="#l2"></a>
143 <span id="l2"></span><a href="#l2"></a>
144 <span id="l3"><span class="sd">&quot;&quot;&quot;Fun with generators. Corresponding Haskell implementation:</span></span><a href="#l3"></a>
144 <span id="l3"><span class="sd">&quot;&quot;&quot;Fun with generators. Corresponding Haskell implementation:</span></span><a href="#l3"></a>
145 <span id="l4"></span><a href="#l4"></a>
145 <span id="l4"></span><a href="#l4"></a>
146 <span id="l5"><span class="sd">primes = 2 : sieve [3, 5..]</span></span><a href="#l5"></a>
146 <span id="l5"><span class="sd">primes = 2 : sieve [3, 5..]</span></span><a href="#l5"></a>
147 <span id="l6"><span class="sd"> where sieve (p:ns) = p : sieve [n | n &lt;- ns, mod n p /= 0]</span></span><a href="#l6"></a>
147 <span id="l6"><span class="sd"> where sieve (p:ns) = p : sieve [n | n &lt;- ns, mod n p /= 0]</span></span><a href="#l6"></a>
148 <span id="l7"><span class="sd">&quot;&quot;&quot;</span></span><a href="#l7"></a>
148 <span id="l7"><span class="sd">&quot;&quot;&quot;</span></span><a href="#l7"></a>
149 <span id="l8"></span><a href="#l8"></a>
149 <span id="l8"></span><a href="#l8"></a>
150 <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>
150 <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>
151 <span id="l10"></span><a href="#l10"></a>
151 <span id="l10"></span><a href="#l10"></a>
152 <span id="l11"><span class="kn">def</span> <span class="nf">primes</span><span class="p">():</span></span><a href="#l11"></a>
152 <span id="l11"><span class="kn">def</span> <span class="nf">primes</span><span class="p">():</span></span><a href="#l11"></a>
153 <span id="l12"> <span class="sd">&quot;&quot;&quot;Generate all primes.&quot;&quot;&quot;</span></span><a href="#l12"></a>
153 <span id="l12"> <span class="sd">&quot;&quot;&quot;Generate all primes.&quot;&quot;&quot;</span></span><a href="#l12"></a>
154 <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>
154 <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>
155 <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>
155 <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>
156 <span id="l15"> <span class="c"># It is important to yield *here* in order to stop the</span></span><a href="#l15"></a>
156 <span id="l15"> <span class="c"># It is important to yield *here* in order to stop the</span></span><a href="#l15"></a>
157 <span id="l16"> <span class="c"># infinite recursion.</span></span><a href="#l16"></a>
157 <span id="l16"> <span class="c"># infinite recursion.</span></span><a href="#l16"></a>
158 <span id="l17"> <span class="kn">yield</span> <span class="n">p</span></span><a href="#l17"></a>
158 <span id="l17"> <span class="kn">yield</span> <span class="n">p</span></span><a href="#l17"></a>
159 <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>
159 <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>
160 <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>
160 <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>
161 <span id="l20"> <span class="kn">yield</span> <span class="n">n</span></span><a href="#l20"></a>
161 <span id="l20"> <span class="kn">yield</span> <span class="n">n</span></span><a href="#l20"></a>
162 <span id="l21"></span><a href="#l21"></a>
162 <span id="l21"></span><a href="#l21"></a>
163 <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>
163 <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>
164 <span id="l23"> <span class="kn">return</span> <span class="n">chain</span><span class="p">([</span><span class="mi">2</span><span class="p">],</span> <span class="n">sieve</span><span class="p">(</span><span class="n">dropwhile</span><span class="p">(</span><span class="kn">lambda</span> <span class="n">n</span><span class="p">:</span> <span class="n">n</span> <span class="o">&lt;</span> <span class="mi">3</span><span class="p">,</span> <span class="n">odds</span><span class="p">)))</span></span><a href="#l23"></a>
164 <span id="l23"> <span class="kn">return</span> <span class="n">chain</span><span class="p">([</span><span class="mi">2</span><span class="p">],</span> <span class="n">sieve</span><span class="p">(</span><span class="n">dropwhile</span><span class="p">(</span><span class="kn">lambda</span> <span class="n">n</span><span class="p">:</span> <span class="n">n</span> <span class="o">&lt;</span> <span class="mi">3</span><span class="p">,</span> <span class="n">odds</span><span class="p">)))</span></span><a href="#l23"></a>
165 <span id="l24"></span><a href="#l24"></a>
165 <span id="l24"></span><a href="#l24"></a>
166 <span id="l25"><span class="kn">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">&quot;__main__&quot;</span><span class="p">:</span></span><a href="#l25"></a>
166 <span id="l25"><span class="kn">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">&quot;__main__&quot;</span><span class="p">:</span></span><a href="#l25"></a>
167 <span id="l26"> <span class="kn">import</span> <span class="nn">sys</span></span><a href="#l26"></a>
167 <span id="l26"> <span class="kn">import</span> <span class="nn">sys</span></span><a href="#l26"></a>
168 <span id="l27"> <span class="kn">try</span><span class="p">:</span></span><a href="#l27"></a>
168 <span id="l27"> <span class="kn">try</span><span class="p">:</span></span><a href="#l27"></a>
169 <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>
169 <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>
170 <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>
170 <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>
171 <span id="l30"> <span class="n">n</span> <span class="o">=</span> <span class="mi">10</span></span><a href="#l30"></a>
171 <span id="l30"> <span class="n">n</span> <span class="o">=</span> <span class="mi">10</span></span><a href="#l30"></a>
172 <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>
172 <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>
173 <span id="l32"> <span class="kn">print</span> <span class="s">&quot;The first </span><span class="si">%d</span><span class="s"> primes: </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="nb">list</span><span class="p">(</span><span class="n">islice</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">n</span><span class="p">)))</span></span><a href="#l32"></a></pre>
173 <span id="l32"> <span class="kn">print</span> <span class="s">&quot;The first </span><span class="si">%d</span><span class="s"> primes: </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="nb">list</span><span class="p">(</span><span class="n">islice</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">n</span><span class="p">)))</span></span><a href="#l32"></a></pre>
174 <div class="sourcelast"></div>
174 <div class="sourcelast"></div>
175 </div>
175 </div>
176 </div>
176 </div>
177 </div>
177 </div>
178
178
179 <script type="text/javascript">process_dates()</script>
179 <script type="text/javascript">process_dates()</script>
180
180
181
181
182 </body>
182 </body>
183 </html>
183 </html>
184
184
185
185
186 hgweb fileannotate, html
186 hgweb fileannotate, html
187
187
188 $ ("$TESTDIR/get-with-headers.py" localhost:$HGPORT 'annotate/tip/primes.py') \
188 $ ("$TESTDIR/get-with-headers.py" localhost:$HGPORT 'annotate/tip/primes.py') \
189 > | sed "s/class=\"k\"/class=\"kn\"/g" | sed "s/class=\"mi\"/class=\"mf\"/g"
189 > | sed "s/class=\"k\"/class=\"kn\"/g" | sed "s/class=\"mi\"/class=\"mf\"/g"
190 200 Script output follows
190 200 Script output follows
191
191
192 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
192 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
193 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
193 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
194 <head>
194 <head>
195 <link rel="icon" href="/static/hgicon.png" type="image/png" />
195 <link rel="icon" href="/static/hgicon.png" type="image/png" />
196 <meta name="robots" content="index, nofollow" />
196 <meta name="robots" content="index, nofollow" />
197 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
197 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
198 <script type="text/javascript" src="/static/mercurial.js"></script>
198 <script type="text/javascript" src="/static/mercurial.js"></script>
199
199
200 <link rel="stylesheet" href="/highlightcss" type="text/css" />
200 <link rel="stylesheet" href="/highlightcss" type="text/css" />
201 <title>test: primes.py annotate</title>
201 <title>test: primes.py annotate</title>
202 </head>
202 </head>
203 <body>
203 <body>
204
204
205 <div class="container">
205 <div class="container">
206 <div class="menu">
206 <div class="menu">
207 <div class="logo">
207 <div class="logo">
208 <a href="http://mercurial.selenic.com/">
208 <a href="http://mercurial.selenic.com/">
209 <img src="/static/hglogo.png" alt="mercurial" /></a>
209 <img src="/static/hglogo.png" alt="mercurial" /></a>
210 </div>
210 </div>
211 <ul>
211 <ul>
212 <li><a href="/shortlog/853dcd4de2a6">log</a></li>
212 <li><a href="/shortlog/853dcd4de2a6">log</a></li>
213 <li><a href="/graph/853dcd4de2a6">graph</a></li>
213 <li><a href="/graph/853dcd4de2a6">graph</a></li>
214 <li><a href="/tags">tags</a></li>
214 <li><a href="/tags">tags</a></li>
215 <li><a href="/bookmarks">bookmarks</a></li>
215 <li><a href="/bookmarks">bookmarks</a></li>
216 <li><a href="/branches">branches</a></li>
216 <li><a href="/branches">branches</a></li>
217 </ul>
217 </ul>
218
218
219 <ul>
219 <ul>
220 <li><a href="/rev/853dcd4de2a6">changeset</a></li>
220 <li><a href="/rev/853dcd4de2a6">changeset</a></li>
221 <li><a href="/file/853dcd4de2a6/">browse</a></li>
221 <li><a href="/file/853dcd4de2a6/">browse</a></li>
222 </ul>
222 </ul>
223 <ul>
223 <ul>
224 <li><a href="/file/853dcd4de2a6/primes.py">file</a></li>
224 <li><a href="/file/853dcd4de2a6/primes.py">file</a></li>
225 <li><a href="/file/tip/primes.py">latest</a></li>
225 <li><a href="/file/tip/primes.py">latest</a></li>
226 <li><a href="/diff/853dcd4de2a6/primes.py">diff</a></li>
226 <li><a href="/diff/853dcd4de2a6/primes.py">diff</a></li>
227 <li><a href="/comparison/853dcd4de2a6/primes.py">comparison</a></li>
227 <li><a href="/comparison/853dcd4de2a6/primes.py">comparison</a></li>
228 <li class="active">annotate</li>
228 <li class="active">annotate</li>
229 <li><a href="/log/853dcd4de2a6/primes.py">file log</a></li>
229 <li><a href="/log/853dcd4de2a6/primes.py">file log</a></li>
230 <li><a href="/raw-annotate/853dcd4de2a6/primes.py">raw</a></li>
230 <li><a href="/raw-annotate/853dcd4de2a6/primes.py">raw</a></li>
231 </ul>
231 </ul>
232 <ul>
232 <ul>
233 <li><a href="/help">help</a></li>
233 <li><a href="/help">help</a></li>
234 </ul>
234 </ul>
235 </div>
235 </div>
236
236
237 <div class="main">
237 <div class="main">
238 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
238 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
239 <h3>annotate primes.py @ 0:853dcd4de2a6</h3>
239 <h3>annotate primes.py @ 0:853dcd4de2a6</h3>
240
240
241 <form class="search" action="/log">
241 <form class="search" action="/log">
242
242
243 <p><input name="rev" id="search1" type="text" size="30" /></p>
243 <p><input name="rev" id="search1" type="text" size="30" /></p>
244 <div id="hint">find changesets by author, revision,
244 <div id="hint">find changesets by author, revision,
245 files, or words in the commit message</div>
245 files, or words in the commit message</div>
246 </form>
246 </form>
247
247
248 <div class="description">a</div>
248 <div class="description">a</div>
249
249
250 <table id="changesetEntry">
250 <table id="changesetEntry">
251 <tr>
251 <tr>
252 <th class="author">author</th>
252 <th class="author">author</th>
253 <td class="author">&#116;&#101;&#115;&#116;</td>
253 <td class="author">&#116;&#101;&#115;&#116;</td>
254 </tr>
254 </tr>
255 <tr>
255 <tr>
256 <th class="date">date</th>
256 <th class="date">date</th>
257 <td class="date age">Thu, 01 Jan 1970 00:00:00 +0000</td>
257 <td class="date age">Thu, 01 Jan 1970 00:00:00 +0000</td>
258 </tr>
258 </tr>
259 <tr>
259 <tr>
260 <th class="author">parents</th>
260 <th class="author">parents</th>
261 <td class="author"></td>
261 <td class="author"></td>
262 </tr>
262 </tr>
263 <tr>
263 <tr>
264 <th class="author">children</th>
264 <th class="author">children</th>
265 <td class="author"></td>
265 <td class="author"></td>
266 </tr>
266 </tr>
267
267
268 </table>
268 </table>
269
269
270 <div class="overflow">
270 <div class="overflow">
271 <table class="bigtable">
271 <table class="bigtable">
272 <tr>
272 <tr>
273 <th class="annotate">rev</th>
273 <th class="annotate">rev</th>
274 <th class="line">&nbsp;&nbsp;line source</th>
274 <th class="line">&nbsp;&nbsp;line source</th>
275 </tr>
275 </tr>
276 <tbody class="stripes2">
276 <tbody class="stripes2">
277
277
278 <tr>
278 <tr id="l1">
279 <td class="annotate">
279 <td class="annotate">
280 <a href="/annotate/853dcd4de2a6/primes.py#l1"
280 <a href="/annotate/853dcd4de2a6/primes.py#l1"
281 title="853dcd4de2a6: a">test@0</a>
281 title="853dcd4de2a6: a">test@0</a>
282 </td>
282 </td>
283 <td class="source"><a href="#l1" id="l1"> 1</a> <span class="c">#!/usr/bin/env python</span></td>
283 <td class="source"><a href="#l1"> 1</a> <span class="c">#!/usr/bin/env python</span></td>
284 </tr>
284 </tr>
285 <tr>
285 <tr id="l2">
286 <td class="annotate">
286 <td class="annotate">
287 <a href="/annotate/853dcd4de2a6/primes.py#l2"
287 <a href="/annotate/853dcd4de2a6/primes.py#l2"
288 title="853dcd4de2a6: a">test@0</a>
288 title="853dcd4de2a6: a">test@0</a>
289 </td>
289 </td>
290 <td class="source"><a href="#l2" id="l2"> 2</a> </td>
290 <td class="source"><a href="#l2"> 2</a> </td>
291 </tr>
291 </tr>
292 <tr>
292 <tr id="l3">
293 <td class="annotate">
293 <td class="annotate">
294 <a href="/annotate/853dcd4de2a6/primes.py#l3"
294 <a href="/annotate/853dcd4de2a6/primes.py#l3"
295 title="853dcd4de2a6: a">test@0</a>
295 title="853dcd4de2a6: a">test@0</a>
296 </td>
296 </td>
297 <td class="source"><a href="#l3" id="l3"> 3</a> <span class="sd">&quot;&quot;&quot;Fun with generators. Corresponding Haskell implementation:</span></td>
297 <td class="source"><a href="#l3"> 3</a> <span class="sd">&quot;&quot;&quot;Fun with generators. Corresponding Haskell implementation:</span></td>
298 </tr>
298 </tr>
299 <tr>
299 <tr id="l4">
300 <td class="annotate">
300 <td class="annotate">
301 <a href="/annotate/853dcd4de2a6/primes.py#l4"
301 <a href="/annotate/853dcd4de2a6/primes.py#l4"
302 title="853dcd4de2a6: a">test@0</a>
302 title="853dcd4de2a6: a">test@0</a>
303 </td>
303 </td>
304 <td class="source"><a href="#l4" id="l4"> 4</a> </td>
304 <td class="source"><a href="#l4"> 4</a> </td>
305 </tr>
305 </tr>
306 <tr>
306 <tr id="l5">
307 <td class="annotate">
307 <td class="annotate">
308 <a href="/annotate/853dcd4de2a6/primes.py#l5"
308 <a href="/annotate/853dcd4de2a6/primes.py#l5"
309 title="853dcd4de2a6: a">test@0</a>
309 title="853dcd4de2a6: a">test@0</a>
310 </td>
310 </td>
311 <td class="source"><a href="#l5" id="l5"> 5</a> <span class="sd">primes = 2 : sieve [3, 5..]</span></td>
311 <td class="source"><a href="#l5"> 5</a> <span class="sd">primes = 2 : sieve [3, 5..]</span></td>
312 </tr>
312 </tr>
313 <tr>
313 <tr id="l6">
314 <td class="annotate">
314 <td class="annotate">
315 <a href="/annotate/853dcd4de2a6/primes.py#l6"
315 <a href="/annotate/853dcd4de2a6/primes.py#l6"
316 title="853dcd4de2a6: a">test@0</a>
316 title="853dcd4de2a6: a">test@0</a>
317 </td>
317 </td>
318 <td class="source"><a href="#l6" id="l6"> 6</a> <span class="sd"> where sieve (p:ns) = p : sieve [n | n &lt;- ns, mod n p /= 0]</span></td>
318 <td class="source"><a href="#l6"> 6</a> <span class="sd"> where sieve (p:ns) = p : sieve [n | n &lt;- ns, mod n p /= 0]</span></td>
319 </tr>
319 </tr>
320 <tr>
320 <tr id="l7">
321 <td class="annotate">
321 <td class="annotate">
322 <a href="/annotate/853dcd4de2a6/primes.py#l7"
322 <a href="/annotate/853dcd4de2a6/primes.py#l7"
323 title="853dcd4de2a6: a">test@0</a>
323 title="853dcd4de2a6: a">test@0</a>
324 </td>
324 </td>
325 <td class="source"><a href="#l7" id="l7"> 7</a> <span class="sd">&quot;&quot;&quot;</span></td>
325 <td class="source"><a href="#l7"> 7</a> <span class="sd">&quot;&quot;&quot;</span></td>
326 </tr>
326 </tr>
327 <tr>
327 <tr id="l8">
328 <td class="annotate">
328 <td class="annotate">
329 <a href="/annotate/853dcd4de2a6/primes.py#l8"
329 <a href="/annotate/853dcd4de2a6/primes.py#l8"
330 title="853dcd4de2a6: a">test@0</a>
330 title="853dcd4de2a6: a">test@0</a>
331 </td>
331 </td>
332 <td class="source"><a href="#l8" id="l8"> 8</a> </td>
332 <td class="source"><a href="#l8"> 8</a> </td>
333 </tr>
333 </tr>
334 <tr>
334 <tr id="l9">
335 <td class="annotate">
335 <td class="annotate">
336 <a href="/annotate/853dcd4de2a6/primes.py#l9"
336 <a href="/annotate/853dcd4de2a6/primes.py#l9"
337 title="853dcd4de2a6: a">test@0</a>
337 title="853dcd4de2a6: a">test@0</a>
338 </td>
338 </td>
339 <td class="source"><a href="#l9" id="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>
339 <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>
340 </tr>
340 </tr>
341 <tr>
341 <tr id="l10">
342 <td class="annotate">
342 <td class="annotate">
343 <a href="/annotate/853dcd4de2a6/primes.py#l10"
343 <a href="/annotate/853dcd4de2a6/primes.py#l10"
344 title="853dcd4de2a6: a">test@0</a>
344 title="853dcd4de2a6: a">test@0</a>
345 </td>
345 </td>
346 <td class="source"><a href="#l10" id="l10"> 10</a> </td>
346 <td class="source"><a href="#l10"> 10</a> </td>
347 </tr>
347 </tr>
348 <tr>
348 <tr id="l11">
349 <td class="annotate">
349 <td class="annotate">
350 <a href="/annotate/853dcd4de2a6/primes.py#l11"
350 <a href="/annotate/853dcd4de2a6/primes.py#l11"
351 title="853dcd4de2a6: a">test@0</a>
351 title="853dcd4de2a6: a">test@0</a>
352 </td>
352 </td>
353 <td class="source"><a href="#l11" id="l11"> 11</a> <span class="kn">def</span> <span class="nf">primes</span><span class="p">():</span></td>
353 <td class="source"><a href="#l11"> 11</a> <span class="kn">def</span> <span class="nf">primes</span><span class="p">():</span></td>
354 </tr>
354 </tr>
355 <tr>
355 <tr id="l12">
356 <td class="annotate">
356 <td class="annotate">
357 <a href="/annotate/853dcd4de2a6/primes.py#l12"
357 <a href="/annotate/853dcd4de2a6/primes.py#l12"
358 title="853dcd4de2a6: a">test@0</a>
358 title="853dcd4de2a6: a">test@0</a>
359 </td>
359 </td>
360 <td class="source"><a href="#l12" id="l12"> 12</a> <span class="sd">&quot;&quot;&quot;Generate all primes.&quot;&quot;&quot;</span></td>
360 <td class="source"><a href="#l12"> 12</a> <span class="sd">&quot;&quot;&quot;Generate all primes.&quot;&quot;&quot;</span></td>
361 </tr>
361 </tr>
362 <tr>
362 <tr id="l13">
363 <td class="annotate">
363 <td class="annotate">
364 <a href="/annotate/853dcd4de2a6/primes.py#l13"
364 <a href="/annotate/853dcd4de2a6/primes.py#l13"
365 title="853dcd4de2a6: a">test@0</a>
365 title="853dcd4de2a6: a">test@0</a>
366 </td>
366 </td>
367 <td class="source"><a href="#l13" id="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>
367 <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>
368 </tr>
368 </tr>
369 <tr>
369 <tr id="l14">
370 <td class="annotate">
370 <td class="annotate">
371 <a href="/annotate/853dcd4de2a6/primes.py#l14"
371 <a href="/annotate/853dcd4de2a6/primes.py#l14"
372 title="853dcd4de2a6: a">test@0</a>
372 title="853dcd4de2a6: a">test@0</a>
373 </td>
373 </td>
374 <td class="source"><a href="#l14" id="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>
374 <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>
375 </tr>
375 </tr>
376 <tr>
376 <tr id="l15">
377 <td class="annotate">
377 <td class="annotate">
378 <a href="/annotate/853dcd4de2a6/primes.py#l15"
378 <a href="/annotate/853dcd4de2a6/primes.py#l15"
379 title="853dcd4de2a6: a">test@0</a>
379 title="853dcd4de2a6: a">test@0</a>
380 </td>
380 </td>
381 <td class="source"><a href="#l15" id="l15"> 15</a> <span class="c"># It is important to yield *here* in order to stop the</span></td>
381 <td class="source"><a href="#l15"> 15</a> <span class="c"># It is important to yield *here* in order to stop the</span></td>
382 </tr>
382 </tr>
383 <tr>
383 <tr id="l16">
384 <td class="annotate">
384 <td class="annotate">
385 <a href="/annotate/853dcd4de2a6/primes.py#l16"
385 <a href="/annotate/853dcd4de2a6/primes.py#l16"
386 title="853dcd4de2a6: a">test@0</a>
386 title="853dcd4de2a6: a">test@0</a>
387 </td>
387 </td>
388 <td class="source"><a href="#l16" id="l16"> 16</a> <span class="c"># infinite recursion.</span></td>
388 <td class="source"><a href="#l16"> 16</a> <span class="c"># infinite recursion.</span></td>
389 </tr>
389 </tr>
390 <tr>
390 <tr id="l17">
391 <td class="annotate">
391 <td class="annotate">
392 <a href="/annotate/853dcd4de2a6/primes.py#l17"
392 <a href="/annotate/853dcd4de2a6/primes.py#l17"
393 title="853dcd4de2a6: a">test@0</a>
393 title="853dcd4de2a6: a">test@0</a>
394 </td>
394 </td>
395 <td class="source"><a href="#l17" id="l17"> 17</a> <span class="kn">yield</span> <span class="n">p</span></td>
395 <td class="source"><a href="#l17"> 17</a> <span class="kn">yield</span> <span class="n">p</span></td>
396 </tr>
396 </tr>
397 <tr>
397 <tr id="l18">
398 <td class="annotate">
398 <td class="annotate">
399 <a href="/annotate/853dcd4de2a6/primes.py#l18"
399 <a href="/annotate/853dcd4de2a6/primes.py#l18"
400 title="853dcd4de2a6: a">test@0</a>
400 title="853dcd4de2a6: a">test@0</a>
401 </td>
401 </td>
402 <td class="source"><a href="#l18" id="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="mf">0</span><span class="p">,</span> <span class="n">ns</span><span class="p">)</span></td>
402 <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="mf">0</span><span class="p">,</span> <span class="n">ns</span><span class="p">)</span></td>
403 </tr>
403 </tr>
404 <tr>
404 <tr id="l19">
405 <td class="annotate">
405 <td class="annotate">
406 <a href="/annotate/853dcd4de2a6/primes.py#l19"
406 <a href="/annotate/853dcd4de2a6/primes.py#l19"
407 title="853dcd4de2a6: a">test@0</a>
407 title="853dcd4de2a6: a">test@0</a>
408 </td>
408 </td>
409 <td class="source"><a href="#l19" id="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>
409 <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>
410 </tr>
410 </tr>
411 <tr>
411 <tr id="l20">
412 <td class="annotate">
412 <td class="annotate">
413 <a href="/annotate/853dcd4de2a6/primes.py#l20"
413 <a href="/annotate/853dcd4de2a6/primes.py#l20"
414 title="853dcd4de2a6: a">test@0</a>
414 title="853dcd4de2a6: a">test@0</a>
415 </td>
415 </td>
416 <td class="source"><a href="#l20" id="l20"> 20</a> <span class="kn">yield</span> <span class="n">n</span></td>
416 <td class="source"><a href="#l20"> 20</a> <span class="kn">yield</span> <span class="n">n</span></td>
417 </tr>
417 </tr>
418 <tr>
418 <tr id="l21">
419 <td class="annotate">
419 <td class="annotate">
420 <a href="/annotate/853dcd4de2a6/primes.py#l21"
420 <a href="/annotate/853dcd4de2a6/primes.py#l21"
421 title="853dcd4de2a6: a">test@0</a>
421 title="853dcd4de2a6: a">test@0</a>
422 </td>
422 </td>
423 <td class="source"><a href="#l21" id="l21"> 21</a> </td>
423 <td class="source"><a href="#l21"> 21</a> </td>
424 </tr>
424 </tr>
425 <tr>
425 <tr id="l22">
426 <td class="annotate">
426 <td class="annotate">
427 <a href="/annotate/853dcd4de2a6/primes.py#l22"
427 <a href="/annotate/853dcd4de2a6/primes.py#l22"
428 title="853dcd4de2a6: a">test@0</a>
428 title="853dcd4de2a6: a">test@0</a>
429 </td>
429 </td>
430 <td class="source"><a href="#l22" id="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="mf">2</span> <span class="o">==</span> <span class="mf">1</span><span class="p">,</span> <span class="n">count</span><span class="p">())</span></td>
430 <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="mf">2</span> <span class="o">==</span> <span class="mf">1</span><span class="p">,</span> <span class="n">count</span><span class="p">())</span></td>
431 </tr>
431 </tr>
432 <tr>
432 <tr id="l23">
433 <td class="annotate">
433 <td class="annotate">
434 <a href="/annotate/853dcd4de2a6/primes.py#l23"
434 <a href="/annotate/853dcd4de2a6/primes.py#l23"
435 title="853dcd4de2a6: a">test@0</a>
435 title="853dcd4de2a6: a">test@0</a>
436 </td>
436 </td>
437 <td class="source"><a href="#l23" id="l23"> 23</a> <span class="kn">return</span> <span class="n">chain</span><span class="p">([</span><span class="mf">2</span><span class="p">],</span> <span class="n">sieve</span><span class="p">(</span><span class="n">dropwhile</span><span class="p">(</span><span class="kn">lambda</span> <span class="n">n</span><span class="p">:</span> <span class="n">n</span> <span class="o">&lt;</span> <span class="mf">3</span><span class="p">,</span> <span class="n">odds</span><span class="p">)))</span></td>
437 <td class="source"><a href="#l23"> 23</a> <span class="kn">return</span> <span class="n">chain</span><span class="p">([</span><span class="mf">2</span><span class="p">],</span> <span class="n">sieve</span><span class="p">(</span><span class="n">dropwhile</span><span class="p">(</span><span class="kn">lambda</span> <span class="n">n</span><span class="p">:</span> <span class="n">n</span> <span class="o">&lt;</span> <span class="mf">3</span><span class="p">,</span> <span class="n">odds</span><span class="p">)))</span></td>
438 </tr>
438 </tr>
439 <tr>
439 <tr id="l24">
440 <td class="annotate">
440 <td class="annotate">
441 <a href="/annotate/853dcd4de2a6/primes.py#l24"
441 <a href="/annotate/853dcd4de2a6/primes.py#l24"
442 title="853dcd4de2a6: a">test@0</a>
442 title="853dcd4de2a6: a">test@0</a>
443 </td>
443 </td>
444 <td class="source"><a href="#l24" id="l24"> 24</a> </td>
444 <td class="source"><a href="#l24"> 24</a> </td>
445 </tr>
445 </tr>
446 <tr>
446 <tr id="l25">
447 <td class="annotate">
447 <td class="annotate">
448 <a href="/annotate/853dcd4de2a6/primes.py#l25"
448 <a href="/annotate/853dcd4de2a6/primes.py#l25"
449 title="853dcd4de2a6: a">test@0</a>
449 title="853dcd4de2a6: a">test@0</a>
450 </td>
450 </td>
451 <td class="source"><a href="#l25" id="l25"> 25</a> <span class="kn">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">&quot;__main__&quot;</span><span class="p">:</span></td>
451 <td class="source"><a href="#l25"> 25</a> <span class="kn">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">&quot;__main__&quot;</span><span class="p">:</span></td>
452 </tr>
452 </tr>
453 <tr>
453 <tr id="l26">
454 <td class="annotate">
454 <td class="annotate">
455 <a href="/annotate/853dcd4de2a6/primes.py#l26"
455 <a href="/annotate/853dcd4de2a6/primes.py#l26"
456 title="853dcd4de2a6: a">test@0</a>
456 title="853dcd4de2a6: a">test@0</a>
457 </td>
457 </td>
458 <td class="source"><a href="#l26" id="l26"> 26</a> <span class="kn">import</span> <span class="nn">sys</span></td>
458 <td class="source"><a href="#l26"> 26</a> <span class="kn">import</span> <span class="nn">sys</span></td>
459 </tr>
459 </tr>
460 <tr>
460 <tr id="l27">
461 <td class="annotate">
461 <td class="annotate">
462 <a href="/annotate/853dcd4de2a6/primes.py#l27"
462 <a href="/annotate/853dcd4de2a6/primes.py#l27"
463 title="853dcd4de2a6: a">test@0</a>
463 title="853dcd4de2a6: a">test@0</a>
464 </td>
464 </td>
465 <td class="source"><a href="#l27" id="l27"> 27</a> <span class="kn">try</span><span class="p">:</span></td>
465 <td class="source"><a href="#l27"> 27</a> <span class="kn">try</span><span class="p">:</span></td>
466 </tr>
466 </tr>
467 <tr>
467 <tr id="l28">
468 <td class="annotate">
468 <td class="annotate">
469 <a href="/annotate/853dcd4de2a6/primes.py#l28"
469 <a href="/annotate/853dcd4de2a6/primes.py#l28"
470 title="853dcd4de2a6: a">test@0</a>
470 title="853dcd4de2a6: a">test@0</a>
471 </td>
471 </td>
472 <td class="source"><a href="#l28" id="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="mf">1</span><span class="p">])</span></td>
472 <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="mf">1</span><span class="p">])</span></td>
473 </tr>
473 </tr>
474 <tr>
474 <tr id="l29">
475 <td class="annotate">
475 <td class="annotate">
476 <a href="/annotate/853dcd4de2a6/primes.py#l29"
476 <a href="/annotate/853dcd4de2a6/primes.py#l29"
477 title="853dcd4de2a6: a">test@0</a>
477 title="853dcd4de2a6: a">test@0</a>
478 </td>
478 </td>
479 <td class="source"><a href="#l29" id="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>
479 <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>
480 </tr>
480 </tr>
481 <tr>
481 <tr id="l30">
482 <td class="annotate">
482 <td class="annotate">
483 <a href="/annotate/853dcd4de2a6/primes.py#l30"
483 <a href="/annotate/853dcd4de2a6/primes.py#l30"
484 title="853dcd4de2a6: a">test@0</a>
484 title="853dcd4de2a6: a">test@0</a>
485 </td>
485 </td>
486 <td class="source"><a href="#l30" id="l30"> 30</a> <span class="n">n</span> <span class="o">=</span> <span class="mf">10</span></td>
486 <td class="source"><a href="#l30"> 30</a> <span class="n">n</span> <span class="o">=</span> <span class="mf">10</span></td>
487 </tr>
487 </tr>
488 <tr>
488 <tr id="l31">
489 <td class="annotate">
489 <td class="annotate">
490 <a href="/annotate/853dcd4de2a6/primes.py#l31"
490 <a href="/annotate/853dcd4de2a6/primes.py#l31"
491 title="853dcd4de2a6: a">test@0</a>
491 title="853dcd4de2a6: a">test@0</a>
492 </td>
492 </td>
493 <td class="source"><a href="#l31" id="l31"> 31</a> <span class="n">p</span> <span class="o">=</span> <span class="n">primes</span><span class="p">()</span></td>
493 <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>
494 </tr>
494 </tr>
495 <tr>
495 <tr id="l32">
496 <td class="annotate">
496 <td class="annotate">
497 <a href="/annotate/853dcd4de2a6/primes.py#l32"
497 <a href="/annotate/853dcd4de2a6/primes.py#l32"
498 title="853dcd4de2a6: a">test@0</a>
498 title="853dcd4de2a6: a">test@0</a>
499 </td>
499 </td>
500 <td class="source"><a href="#l32" id="l32"> 32</a> <span class="kn">print</span> <span class="s">&quot;The first </span><span class="si">%d</span><span class="s"> primes: </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="nb">list</span><span class="p">(</span><span class="n">islice</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">n</span><span class="p">)))</span></td>
500 <td class="source"><a href="#l32"> 32</a> <span class="kn">print</span> <span class="s">&quot;The first </span><span class="si">%d</span><span class="s"> primes: </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="nb">list</span><span class="p">(</span><span class="n">islice</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">n</span><span class="p">)))</span></td>
501 </tr>
501 </tr>
502 </tbody>
502 </tbody>
503 </table>
503 </table>
504 </div>
504 </div>
505 </div>
505 </div>
506 </div>
506 </div>
507
507
508 <script type="text/javascript">process_dates()</script>
508 <script type="text/javascript">process_dates()</script>
509
509
510
510
511 </body>
511 </body>
512 </html>
512 </html>
513
513
514
514
515 hgweb fileannotate, raw
515 hgweb fileannotate, raw
516
516
517 $ ("$TESTDIR/get-with-headers.py" localhost:$HGPORT 'annotate/tip/primes.py?style=raw') \
517 $ ("$TESTDIR/get-with-headers.py" localhost:$HGPORT 'annotate/tip/primes.py?style=raw') \
518 > | sed "s/test@//" > a
518 > | sed "s/test@//" > a
519 $ echo "200 Script output follows" > b
519 $ echo "200 Script output follows" > b
520 $ echo "" >> b
520 $ echo "" >> b
521 $ echo "" >> b
521 $ echo "" >> b
522 $ hg annotate "primes.py" >> b
522 $ hg annotate "primes.py" >> b
523 $ echo "" >> b
523 $ echo "" >> b
524 $ echo "" >> b
524 $ echo "" >> b
525 $ echo "" >> b
525 $ echo "" >> b
526 $ echo "" >> b
526 $ echo "" >> b
527 $ diff -u b a
527 $ diff -u b a
528
528
529 hgweb filerevision, raw
529 hgweb filerevision, raw
530
530
531 $ ("$TESTDIR/get-with-headers.py" localhost:$HGPORT 'file/tip/primes.py?style=raw') \
531 $ ("$TESTDIR/get-with-headers.py" localhost:$HGPORT 'file/tip/primes.py?style=raw') \
532 > > a
532 > > a
533 $ echo "200 Script output follows" > b
533 $ echo "200 Script output follows" > b
534 $ echo "" >> b
534 $ echo "" >> b
535 $ hg cat primes.py >> b
535 $ hg cat primes.py >> b
536 $ diff -u b a
536 $ diff -u b a
537
537
538 hgweb highlightcss friendly
538 hgweb highlightcss friendly
539
539
540 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'highlightcss' > out
540 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'highlightcss' > out
541 $ head -n 4 out
541 $ head -n 4 out
542 200 Script output follows
542 200 Script output follows
543
543
544 /* pygments_style = friendly */
544 /* pygments_style = friendly */
545
545
546 $ rm out
546 $ rm out
547
547
548 errors encountered
548 errors encountered
549
549
550 $ cat errors.log
550 $ cat errors.log
551 $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
551 $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
552
552
553 Change the pygments style
553 Change the pygments style
554
554
555 $ cat > .hg/hgrc <<EOF
555 $ cat > .hg/hgrc <<EOF
556 > [web]
556 > [web]
557 > pygments_style = fruity
557 > pygments_style = fruity
558 > EOF
558 > EOF
559
559
560 hg serve again
560 hg serve again
561
561
562 $ hg serve -p $HGPORT -d -n test --pid-file=hg.pid -A access.log -E errors.log
562 $ hg serve -p $HGPORT -d -n test --pid-file=hg.pid -A access.log -E errors.log
563 $ cat hg.pid >> $DAEMON_PIDS
563 $ cat hg.pid >> $DAEMON_PIDS
564
564
565 hgweb highlightcss fruity
565 hgweb highlightcss fruity
566
566
567 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'highlightcss' > out
567 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'highlightcss' > out
568 $ head -n 4 out
568 $ head -n 4 out
569 200 Script output follows
569 200 Script output follows
570
570
571 /* pygments_style = fruity */
571 /* pygments_style = fruity */
572
572
573 $ rm out
573 $ rm out
574
574
575 errors encountered
575 errors encountered
576
576
577 $ cat errors.log
577 $ cat errors.log
578 $ cd ..
578 $ cd ..
579 $ hg init eucjp
579 $ hg init eucjp
580 $ cd eucjp
580 $ cd eucjp
581 $ python -c 'print("\265\376")' >> eucjp.txt # Japanese kanji "Kyo"
581 $ python -c 'print("\265\376")' >> eucjp.txt # Japanese kanji "Kyo"
582 $ hg ci -Ama
582 $ hg ci -Ama
583 adding eucjp.txt
583 adding eucjp.txt
584 $ hgserveget () {
584 $ hgserveget () {
585 > "$TESTDIR/killdaemons.py" $DAEMON_PIDS
585 > "$TESTDIR/killdaemons.py" $DAEMON_PIDS
586 > echo % HGENCODING="$1" hg serve
586 > echo % HGENCODING="$1" hg serve
587 > HGENCODING="$1" hg serve -p $HGPORT -d -n test --pid-file=hg.pid -E errors.log
587 > HGENCODING="$1" hg serve -p $HGPORT -d -n test --pid-file=hg.pid -E errors.log
588 > cat hg.pid >> $DAEMON_PIDS
588 > cat hg.pid >> $DAEMON_PIDS
589 >
589 >
590 > echo % hgweb filerevision, html
590 > echo % hgweb filerevision, html
591 > "$TESTDIR/get-with-headers.py" localhost:$HGPORT "file/tip/$2" \
591 > "$TESTDIR/get-with-headers.py" localhost:$HGPORT "file/tip/$2" \
592 > | grep '<div class="parity0 source">'
592 > | grep '<div class="parity0 source">'
593 > echo % errors encountered
593 > echo % errors encountered
594 > cat errors.log
594 > cat errors.log
595 > }
595 > }
596 $ hgserveget euc-jp eucjp.txt
596 $ hgserveget euc-jp eucjp.txt
597 % HGENCODING=euc-jp hg serve
597 % HGENCODING=euc-jp hg serve
598 % hgweb filerevision, html
598 % hgweb filerevision, html
599 % errors encountered
599 % errors encountered
600 $ hgserveget utf-8 eucjp.txt
600 $ hgserveget utf-8 eucjp.txt
601 % HGENCODING=utf-8 hg serve
601 % HGENCODING=utf-8 hg serve
602 % hgweb filerevision, html
602 % hgweb filerevision, html
603 % errors encountered
603 % errors encountered
604 $ hgserveget us-ascii eucjp.txt
604 $ hgserveget us-ascii eucjp.txt
605 % HGENCODING=us-ascii hg serve
605 % HGENCODING=us-ascii hg serve
606 % hgweb filerevision, html
606 % hgweb filerevision, html
607 % errors encountered
607 % errors encountered
608
608
609 $ cd ..
609 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now