Show More
@@ -1,39 +1,43 b'' | |||
|
1 | 1 | #!/usr/bin/env python |
|
2 | 2 | # |
|
3 | 3 | # check-py3-compat - check Python 3 compatibility of Mercurial files |
|
4 | 4 | # |
|
5 | 5 | # Copyright 2015 Gregory Szorc <gregory.szorc@gmail.com> |
|
6 | 6 | # |
|
7 | 7 | # This software may be used and distributed according to the terms of the |
|
8 | 8 | # GNU General Public License version 2 or any later version. |
|
9 | 9 | |
|
10 | 10 | from __future__ import absolute_import, print_function |
|
11 | 11 | |
|
12 | 12 | import ast |
|
13 | 13 | import sys |
|
14 | 14 | |
|
15 | 15 | def check_compat(f): |
|
16 | 16 | """Check Python 3 compatibility for a file.""" |
|
17 | 17 | with open(f, 'rb') as fh: |
|
18 | 18 | content = fh.read() |
|
19 | 19 | |
|
20 | # Ignore empty files. | |
|
21 | if not content.strip(): | |
|
22 | return | |
|
23 | ||
|
20 | 24 | root = ast.parse(content) |
|
21 | 25 | futures = set() |
|
22 | 26 | haveprint = False |
|
23 | 27 | for node in ast.walk(root): |
|
24 | 28 | if isinstance(node, ast.ImportFrom): |
|
25 | 29 | if node.module == '__future__': |
|
26 | 30 | futures |= set(n.name for n in node.names) |
|
27 | 31 | elif isinstance(node, ast.Print): |
|
28 | 32 | haveprint = True |
|
29 | 33 | |
|
30 | 34 | if 'absolute_import' not in futures: |
|
31 | 35 | print('%s not using absolute_import' % f) |
|
32 | 36 | if haveprint and 'print_function' not in futures: |
|
33 | 37 | print('%s requires print_function' % f) |
|
34 | 38 | |
|
35 | 39 | if __name__ == '__main__': |
|
36 | 40 | for f in sys.argv[1:]: |
|
37 | 41 | check_compat(f) |
|
38 | 42 | |
|
39 | 43 | sys.exit(0) |
@@ -1,223 +1,221 b'' | |||
|
1 | 1 | #require test-repo |
|
2 | 2 | |
|
3 | 3 | $ cd "$TESTDIR"/.. |
|
4 | 4 | |
|
5 | 5 | $ hg files 'set:(**.py)' | xargs python contrib/check-py3-compat.py |
|
6 | 6 | contrib/casesmash.py not using absolute_import |
|
7 | 7 | contrib/check-code.py not using absolute_import |
|
8 | 8 | contrib/check-code.py requires print_function |
|
9 | 9 | contrib/check-config.py not using absolute_import |
|
10 | 10 | contrib/check-config.py requires print_function |
|
11 | 11 | contrib/debugcmdserver.py not using absolute_import |
|
12 | 12 | contrib/debugcmdserver.py requires print_function |
|
13 | 13 | contrib/debugshell.py not using absolute_import |
|
14 | 14 | contrib/fixpax.py not using absolute_import |
|
15 | 15 | contrib/fixpax.py requires print_function |
|
16 | 16 | contrib/hgclient.py not using absolute_import |
|
17 | 17 | contrib/hgclient.py requires print_function |
|
18 | contrib/hgfixes/__init__.py not using absolute_import | |
|
19 | 18 | contrib/hgfixes/fix_bytes.py not using absolute_import |
|
20 | 19 | contrib/hgfixes/fix_bytesmod.py not using absolute_import |
|
21 | 20 | contrib/hgfixes/fix_leftover_imports.py not using absolute_import |
|
22 | 21 | contrib/import-checker.py not using absolute_import |
|
23 | 22 | contrib/import-checker.py requires print_function |
|
24 | 23 | contrib/memory.py not using absolute_import |
|
25 | 24 | contrib/perf.py not using absolute_import |
|
26 | 25 | contrib/python-hook-examples.py not using absolute_import |
|
27 | 26 | contrib/revsetbenchmarks.py not using absolute_import |
|
28 | 27 | contrib/revsetbenchmarks.py requires print_function |
|
29 | 28 | contrib/showstack.py not using absolute_import |
|
30 | 29 | contrib/synthrepo.py not using absolute_import |
|
31 | 30 | contrib/win32/hgwebdir_wsgi.py not using absolute_import |
|
32 | 31 | doc/check-seclevel.py not using absolute_import |
|
33 | 32 | doc/gendoc.py not using absolute_import |
|
34 | 33 | doc/hgmanpage.py not using absolute_import |
|
35 | 34 | hgext/__init__.py not using absolute_import |
|
36 | 35 | hgext/acl.py not using absolute_import |
|
37 | 36 | hgext/blackbox.py not using absolute_import |
|
38 | 37 | hgext/bugzilla.py not using absolute_import |
|
39 | 38 | hgext/censor.py not using absolute_import |
|
40 | 39 | hgext/children.py not using absolute_import |
|
41 | 40 | hgext/churn.py not using absolute_import |
|
42 | 41 | hgext/clonebundles.py not using absolute_import |
|
43 | 42 | hgext/color.py not using absolute_import |
|
44 | 43 | hgext/convert/__init__.py not using absolute_import |
|
45 | 44 | hgext/convert/bzr.py not using absolute_import |
|
46 | 45 | hgext/convert/common.py not using absolute_import |
|
47 | 46 | hgext/convert/convcmd.py not using absolute_import |
|
48 | 47 | hgext/convert/cvs.py not using absolute_import |
|
49 | 48 | hgext/convert/cvsps.py not using absolute_import |
|
50 | 49 | hgext/convert/darcs.py not using absolute_import |
|
51 | 50 | hgext/convert/filemap.py not using absolute_import |
|
52 | 51 | hgext/convert/git.py not using absolute_import |
|
53 | 52 | hgext/convert/gnuarch.py not using absolute_import |
|
54 | 53 | hgext/convert/hg.py not using absolute_import |
|
55 | 54 | hgext/convert/monotone.py not using absolute_import |
|
56 | 55 | hgext/convert/p4.py not using absolute_import |
|
57 | 56 | hgext/convert/subversion.py not using absolute_import |
|
58 | 57 | hgext/convert/transport.py not using absolute_import |
|
59 | 58 | hgext/eol.py not using absolute_import |
|
60 | 59 | hgext/extdiff.py not using absolute_import |
|
61 | 60 | hgext/factotum.py not using absolute_import |
|
62 | 61 | hgext/fetch.py not using absolute_import |
|
63 | 62 | hgext/gpg.py not using absolute_import |
|
64 | 63 | hgext/graphlog.py not using absolute_import |
|
65 | 64 | hgext/hgcia.py not using absolute_import |
|
66 | 65 | hgext/hgk.py not using absolute_import |
|
67 | 66 | hgext/highlight/__init__.py not using absolute_import |
|
68 | 67 | hgext/highlight/highlight.py not using absolute_import |
|
69 | 68 | hgext/histedit.py not using absolute_import |
|
70 | 69 | hgext/keyword.py not using absolute_import |
|
71 | 70 | hgext/largefiles/__init__.py not using absolute_import |
|
72 | 71 | hgext/largefiles/basestore.py not using absolute_import |
|
73 | 72 | hgext/largefiles/lfcommands.py not using absolute_import |
|
74 | 73 | hgext/largefiles/lfutil.py not using absolute_import |
|
75 | 74 | hgext/largefiles/localstore.py not using absolute_import |
|
76 | 75 | hgext/largefiles/overrides.py not using absolute_import |
|
77 | 76 | hgext/largefiles/proto.py not using absolute_import |
|
78 | 77 | hgext/largefiles/remotestore.py not using absolute_import |
|
79 | 78 | hgext/largefiles/reposetup.py not using absolute_import |
|
80 | 79 | hgext/largefiles/uisetup.py not using absolute_import |
|
81 | 80 | hgext/largefiles/wirestore.py not using absolute_import |
|
82 | 81 | hgext/mq.py not using absolute_import |
|
83 | 82 | hgext/notify.py not using absolute_import |
|
84 | 83 | hgext/pager.py not using absolute_import |
|
85 | 84 | hgext/patchbomb.py not using absolute_import |
|
86 | 85 | hgext/purge.py not using absolute_import |
|
87 | 86 | hgext/rebase.py not using absolute_import |
|
88 | 87 | hgext/record.py not using absolute_import |
|
89 | 88 | hgext/relink.py not using absolute_import |
|
90 | 89 | hgext/schemes.py not using absolute_import |
|
91 | 90 | hgext/share.py not using absolute_import |
|
92 | 91 | hgext/shelve.py not using absolute_import |
|
93 | 92 | hgext/strip.py not using absolute_import |
|
94 | 93 | hgext/transplant.py not using absolute_import |
|
95 | 94 | hgext/win32mbcs.py not using absolute_import |
|
96 | 95 | hgext/win32text.py not using absolute_import |
|
97 | 96 | hgext/zeroconf/Zeroconf.py not using absolute_import |
|
98 | 97 | hgext/zeroconf/Zeroconf.py requires print_function |
|
99 | 98 | hgext/zeroconf/__init__.py not using absolute_import |
|
100 | 99 | i18n/check-translation.py not using absolute_import |
|
101 | 100 | i18n/polib.py not using absolute_import |
|
102 | 101 | mercurial/byterange.py not using absolute_import |
|
103 | 102 | mercurial/cmdutil.py not using absolute_import |
|
104 | 103 | mercurial/commands.py not using absolute_import |
|
105 | 104 | mercurial/commandserver.py not using absolute_import |
|
106 | 105 | mercurial/context.py not using absolute_import |
|
107 | 106 | mercurial/destutil.py not using absolute_import |
|
108 | 107 | mercurial/dirstate.py not using absolute_import |
|
109 | 108 | mercurial/dispatch.py requires print_function |
|
110 | 109 | mercurial/encoding.py not using absolute_import |
|
111 | 110 | mercurial/exchange.py not using absolute_import |
|
112 | 111 | mercurial/help.py not using absolute_import |
|
113 | 112 | mercurial/httpclient/__init__.py not using absolute_import |
|
114 | 113 | mercurial/httpclient/_readers.py not using absolute_import |
|
115 | 114 | mercurial/httpclient/socketutil.py not using absolute_import |
|
116 | 115 | mercurial/httpconnection.py not using absolute_import |
|
117 | 116 | mercurial/keepalive.py not using absolute_import |
|
118 | 117 | mercurial/keepalive.py requires print_function |
|
119 | 118 | mercurial/localrepo.py not using absolute_import |
|
120 | 119 | mercurial/lsprof.py requires print_function |
|
121 | 120 | mercurial/lsprofcalltree.py not using absolute_import |
|
122 | 121 | mercurial/lsprofcalltree.py requires print_function |
|
123 | 122 | mercurial/mail.py requires print_function |
|
124 | 123 | mercurial/manifest.py not using absolute_import |
|
125 | 124 | mercurial/mdiff.py not using absolute_import |
|
126 | 125 | mercurial/obsolete.py not using absolute_import |
|
127 | 126 | mercurial/patch.py not using absolute_import |
|
128 | mercurial/pure/__init__.py not using absolute_import | |
|
129 | 127 | mercurial/pure/base85.py not using absolute_import |
|
130 | 128 | mercurial/pure/bdiff.py not using absolute_import |
|
131 | 129 | mercurial/pure/diffhelpers.py not using absolute_import |
|
132 | 130 | mercurial/pure/mpatch.py not using absolute_import |
|
133 | 131 | mercurial/pure/osutil.py not using absolute_import |
|
134 | 132 | mercurial/pure/parsers.py not using absolute_import |
|
135 | 133 | mercurial/pvec.py not using absolute_import |
|
136 | 134 | mercurial/py3kcompat.py not using absolute_import |
|
137 | 135 | mercurial/revlog.py not using absolute_import |
|
138 | 136 | mercurial/scmposix.py not using absolute_import |
|
139 | 137 | mercurial/scmutil.py not using absolute_import |
|
140 | 138 | mercurial/scmwindows.py not using absolute_import |
|
141 | 139 | mercurial/similar.py not using absolute_import |
|
142 | 140 | mercurial/store.py not using absolute_import |
|
143 | 141 | mercurial/util.py not using absolute_import |
|
144 | 142 | mercurial/windows.py not using absolute_import |
|
145 | 143 | setup.py not using absolute_import |
|
146 | 144 | tests/filterpyflakes.py requires print_function |
|
147 | 145 | tests/generate-working-copy-states.py requires print_function |
|
148 | 146 | tests/get-with-headers.py requires print_function |
|
149 | 147 | tests/heredoctest.py requires print_function |
|
150 | 148 | tests/hypothesishelpers.py not using absolute_import |
|
151 | 149 | tests/hypothesishelpers.py requires print_function |
|
152 | 150 | tests/killdaemons.py not using absolute_import |
|
153 | 151 | tests/md5sum.py not using absolute_import |
|
154 | 152 | tests/mockblackbox.py not using absolute_import |
|
155 | 153 | tests/printenv.py not using absolute_import |
|
156 | 154 | tests/readlink.py not using absolute_import |
|
157 | 155 | tests/readlink.py requires print_function |
|
158 | 156 | tests/revlog-formatv0.py not using absolute_import |
|
159 | 157 | tests/run-tests.py not using absolute_import |
|
160 | 158 | tests/seq.py not using absolute_import |
|
161 | 159 | tests/seq.py requires print_function |
|
162 | 160 | tests/silenttestrunner.py not using absolute_import |
|
163 | 161 | tests/silenttestrunner.py requires print_function |
|
164 | 162 | tests/sitecustomize.py not using absolute_import |
|
165 | 163 | tests/svn-safe-append.py not using absolute_import |
|
166 | 164 | tests/svnxml.py not using absolute_import |
|
167 | 165 | tests/test-ancestor.py requires print_function |
|
168 | 166 | tests/test-atomictempfile.py not using absolute_import |
|
169 | 167 | tests/test-batching.py not using absolute_import |
|
170 | 168 | tests/test-batching.py requires print_function |
|
171 | 169 | tests/test-bdiff.py not using absolute_import |
|
172 | 170 | tests/test-bdiff.py requires print_function |
|
173 | 171 | tests/test-context.py not using absolute_import |
|
174 | 172 | tests/test-context.py requires print_function |
|
175 | 173 | tests/test-demandimport.py not using absolute_import |
|
176 | 174 | tests/test-demandimport.py requires print_function |
|
177 | 175 | tests/test-dispatch.py not using absolute_import |
|
178 | 176 | tests/test-dispatch.py requires print_function |
|
179 | 177 | tests/test-doctest.py not using absolute_import |
|
180 | 178 | tests/test-duplicateoptions.py not using absolute_import |
|
181 | 179 | tests/test-duplicateoptions.py requires print_function |
|
182 | 180 | tests/test-filecache.py not using absolute_import |
|
183 | 181 | tests/test-filecache.py requires print_function |
|
184 | 182 | tests/test-filelog.py not using absolute_import |
|
185 | 183 | tests/test-filelog.py requires print_function |
|
186 | 184 | tests/test-hg-parseurl.py not using absolute_import |
|
187 | 185 | tests/test-hg-parseurl.py requires print_function |
|
188 | 186 | tests/test-hgweb-auth.py not using absolute_import |
|
189 | 187 | tests/test-hgweb-auth.py requires print_function |
|
190 | 188 | tests/test-hgwebdir-paths.py not using absolute_import |
|
191 | 189 | tests/test-hybridencode.py not using absolute_import |
|
192 | 190 | tests/test-hybridencode.py requires print_function |
|
193 | 191 | tests/test-lrucachedict.py not using absolute_import |
|
194 | 192 | tests/test-lrucachedict.py requires print_function |
|
195 | 193 | tests/test-manifest.py not using absolute_import |
|
196 | 194 | tests/test-minirst.py not using absolute_import |
|
197 | 195 | tests/test-minirst.py requires print_function |
|
198 | 196 | tests/test-parseindex2.py not using absolute_import |
|
199 | 197 | tests/test-parseindex2.py requires print_function |
|
200 | 198 | tests/test-pathencode.py not using absolute_import |
|
201 | 199 | tests/test-pathencode.py requires print_function |
|
202 | 200 | tests/test-propertycache.py not using absolute_import |
|
203 | 201 | tests/test-propertycache.py requires print_function |
|
204 | 202 | tests/test-revlog-ancestry.py not using absolute_import |
|
205 | 203 | tests/test-revlog-ancestry.py requires print_function |
|
206 | 204 | tests/test-run-tests.py not using absolute_import |
|
207 | 205 | tests/test-simplemerge.py not using absolute_import |
|
208 | 206 | tests/test-status-inprocess.py not using absolute_import |
|
209 | 207 | tests/test-status-inprocess.py requires print_function |
|
210 | 208 | tests/test-symlink-os-yes-fs-no.py not using absolute_import |
|
211 | 209 | tests/test-trusted.py not using absolute_import |
|
212 | 210 | tests/test-trusted.py requires print_function |
|
213 | 211 | tests/test-ui-color.py not using absolute_import |
|
214 | 212 | tests/test-ui-color.py requires print_function |
|
215 | 213 | tests/test-ui-config.py not using absolute_import |
|
216 | 214 | tests/test-ui-config.py requires print_function |
|
217 | 215 | tests/test-ui-verbosity.py not using absolute_import |
|
218 | 216 | tests/test-ui-verbosity.py requires print_function |
|
219 | 217 | tests/test-url.py not using absolute_import |
|
220 | 218 | tests/test-url.py requires print_function |
|
221 | 219 | tests/test-walkrepo.py requires print_function |
|
222 | 220 | tests/test-wireproto.py requires print_function |
|
223 | 221 | tests/tinyproxy.py requires print_function |
General Comments 0
You need to be logged in to leave comments.
Login now