##// END OF EJS Templates
fixpax: use absolute_import and print_function
Pulkit Goyal -
r28354:00f31778 default
parent child Browse files
Show More
@@ -1,61 +1,64 b''
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2 # fixpax - fix ownership in bdist_mpkg output
2 # fixpax - fix ownership in bdist_mpkg output
3 #
3 #
4 # Copyright 2015 Matt Mackall <mpm@selenic.com>
4 # Copyright 2015 Matt Mackall <mpm@selenic.com>
5 #
5 #
6 # This software may be used and distributed according to the terms of the
6 # This software may be used and distributed according to the terms of the
7 # MIT license (http://opensource.org/licenses/MIT)
7 # MIT license (http://opensource.org/licenses/MIT)
8
8
9 """Set file ownership to 0 in an Archive.pax.gz.
9 """Set file ownership to 0 in an Archive.pax.gz.
10 Suitable for fixing files bdist_mpkg output:
10 Suitable for fixing files bdist_mpkg output:
11 *.mpkg/Contents/Packages/*.pkg/Contents/Archive.pax.gz
11 *.mpkg/Contents/Packages/*.pkg/Contents/Archive.pax.gz
12 """
12 """
13
13
14 import sys, os, gzip
14 from __future__ import absolute_import, print_function
15 import gzip
16 import os
17 import sys
15
18
16 def fixpax(iname, oname):
19 def fixpax(iname, oname):
17 i = gzip.GzipFile(iname)
20 i = gzip.GzipFile(iname)
18 o = gzip.GzipFile(oname, "w")
21 o = gzip.GzipFile(oname, "w")
19
22
20 while True:
23 while True:
21 magic = i.read(6)
24 magic = i.read(6)
22 dev = i.read(6)
25 dev = i.read(6)
23 ino = i.read(6)
26 ino = i.read(6)
24 mode = i.read(6)
27 mode = i.read(6)
25 i.read(6) # uid
28 i.read(6) # uid
26 i.read(6) # gid
29 i.read(6) # gid
27 nlink = i.read(6)
30 nlink = i.read(6)
28 rdev = i.read(6)
31 rdev = i.read(6)
29 mtime = i.read(11)
32 mtime = i.read(11)
30 namesize = i.read(6)
33 namesize = i.read(6)
31 filesize = i.read(11)
34 filesize = i.read(11)
32 name = i.read(int(namesize, 8))
35 name = i.read(int(namesize, 8))
33 data = i.read(int(filesize, 8))
36 data = i.read(int(filesize, 8))
34
37
35 o.write(magic)
38 o.write(magic)
36 o.write(dev)
39 o.write(dev)
37 o.write(ino)
40 o.write(ino)
38 o.write(mode)
41 o.write(mode)
39 o.write("000000")
42 o.write("000000")
40 o.write("000000")
43 o.write("000000")
41 o.write(nlink)
44 o.write(nlink)
42 o.write(rdev)
45 o.write(rdev)
43 o.write(mtime)
46 o.write(mtime)
44 o.write(namesize)
47 o.write(namesize)
45 o.write(filesize)
48 o.write(filesize)
46 o.write(name)
49 o.write(name)
47 o.write(data)
50 o.write(data)
48
51
49 if name.startswith("TRAILER!!!"):
52 if name.startswith("TRAILER!!!"):
50 o.write(i.read())
53 o.write(i.read())
51 break
54 break
52
55
53 o.close()
56 o.close()
54 i.close()
57 i.close()
55
58
56 if __name__ == '__main__':
59 if __name__ == '__main__':
57 for iname in sys.argv[1:]:
60 for iname in sys.argv[1:]:
58 print 'fixing file ownership in %s' % iname
61 print('fixing file ownership in %s' % iname)
59 oname = sys.argv[1] + '.tmp'
62 oname = sys.argv[1] + '.tmp'
60 fixpax(iname, oname)
63 fixpax(iname, oname)
61 os.rename(oname, iname)
64 os.rename(oname, iname)
@@ -1,162 +1,160 b''
1 #require test-repo
1 #require test-repo
2
2
3 $ cd "$TESTDIR"/..
3 $ cd "$TESTDIR"/..
4
4
5 $ hg files 'set:(**.py)' | sed 's|\\|/|g' | xargs python contrib/check-py3-compat.py
5 $ hg files 'set:(**.py)' | sed 's|\\|/|g' | xargs python contrib/check-py3-compat.py
6 contrib/check-code.py not using absolute_import
6 contrib/check-code.py not using absolute_import
7 contrib/check-code.py requires print_function
7 contrib/check-code.py requires print_function
8 contrib/debugshell.py not using absolute_import
8 contrib/debugshell.py not using absolute_import
9 contrib/fixpax.py not using absolute_import
10 contrib/fixpax.py requires print_function
11 contrib/hgclient.py not using absolute_import
9 contrib/hgclient.py not using absolute_import
12 contrib/hgclient.py requires print_function
10 contrib/hgclient.py requires print_function
13 contrib/hgfixes/fix_bytes.py not using absolute_import
11 contrib/hgfixes/fix_bytes.py not using absolute_import
14 contrib/hgfixes/fix_bytesmod.py not using absolute_import
12 contrib/hgfixes/fix_bytesmod.py not using absolute_import
15 contrib/hgfixes/fix_leftover_imports.py not using absolute_import
13 contrib/hgfixes/fix_leftover_imports.py not using absolute_import
16 contrib/import-checker.py not using absolute_import
14 contrib/import-checker.py not using absolute_import
17 contrib/import-checker.py requires print_function
15 contrib/import-checker.py requires print_function
18 contrib/memory.py not using absolute_import
16 contrib/memory.py not using absolute_import
19 contrib/perf.py not using absolute_import
17 contrib/perf.py not using absolute_import
20 contrib/python-hook-examples.py not using absolute_import
18 contrib/python-hook-examples.py not using absolute_import
21 contrib/revsetbenchmarks.py not using absolute_import
19 contrib/revsetbenchmarks.py not using absolute_import
22 contrib/revsetbenchmarks.py requires print_function
20 contrib/revsetbenchmarks.py requires print_function
23 contrib/showstack.py not using absolute_import
21 contrib/showstack.py not using absolute_import
24 contrib/synthrepo.py not using absolute_import
22 contrib/synthrepo.py not using absolute_import
25 contrib/win32/hgwebdir_wsgi.py not using absolute_import
23 contrib/win32/hgwebdir_wsgi.py not using absolute_import
26 doc/check-seclevel.py not using absolute_import
24 doc/check-seclevel.py not using absolute_import
27 doc/gendoc.py not using absolute_import
25 doc/gendoc.py not using absolute_import
28 doc/hgmanpage.py not using absolute_import
26 doc/hgmanpage.py not using absolute_import
29 hgext/__init__.py not using absolute_import
27 hgext/__init__.py not using absolute_import
30 hgext/color.py not using absolute_import
28 hgext/color.py not using absolute_import
31 hgext/convert/__init__.py not using absolute_import
29 hgext/convert/__init__.py not using absolute_import
32 hgext/convert/bzr.py not using absolute_import
30 hgext/convert/bzr.py not using absolute_import
33 hgext/convert/common.py not using absolute_import
31 hgext/convert/common.py not using absolute_import
34 hgext/convert/convcmd.py not using absolute_import
32 hgext/convert/convcmd.py not using absolute_import
35 hgext/convert/cvs.py not using absolute_import
33 hgext/convert/cvs.py not using absolute_import
36 hgext/convert/cvsps.py not using absolute_import
34 hgext/convert/cvsps.py not using absolute_import
37 hgext/convert/darcs.py not using absolute_import
35 hgext/convert/darcs.py not using absolute_import
38 hgext/convert/filemap.py not using absolute_import
36 hgext/convert/filemap.py not using absolute_import
39 hgext/convert/git.py not using absolute_import
37 hgext/convert/git.py not using absolute_import
40 hgext/convert/gnuarch.py not using absolute_import
38 hgext/convert/gnuarch.py not using absolute_import
41 hgext/convert/hg.py not using absolute_import
39 hgext/convert/hg.py not using absolute_import
42 hgext/convert/monotone.py not using absolute_import
40 hgext/convert/monotone.py not using absolute_import
43 hgext/convert/p4.py not using absolute_import
41 hgext/convert/p4.py not using absolute_import
44 hgext/convert/subversion.py not using absolute_import
42 hgext/convert/subversion.py not using absolute_import
45 hgext/convert/transport.py not using absolute_import
43 hgext/convert/transport.py not using absolute_import
46 hgext/eol.py not using absolute_import
44 hgext/eol.py not using absolute_import
47 hgext/extdiff.py not using absolute_import
45 hgext/extdiff.py not using absolute_import
48 hgext/factotum.py not using absolute_import
46 hgext/factotum.py not using absolute_import
49 hgext/fetch.py not using absolute_import
47 hgext/fetch.py not using absolute_import
50 hgext/gpg.py not using absolute_import
48 hgext/gpg.py not using absolute_import
51 hgext/graphlog.py not using absolute_import
49 hgext/graphlog.py not using absolute_import
52 hgext/hgcia.py not using absolute_import
50 hgext/hgcia.py not using absolute_import
53 hgext/hgk.py not using absolute_import
51 hgext/hgk.py not using absolute_import
54 hgext/highlight/__init__.py not using absolute_import
52 hgext/highlight/__init__.py not using absolute_import
55 hgext/highlight/highlight.py not using absolute_import
53 hgext/highlight/highlight.py not using absolute_import
56 hgext/histedit.py not using absolute_import
54 hgext/histedit.py not using absolute_import
57 hgext/largefiles/__init__.py not using absolute_import
55 hgext/largefiles/__init__.py not using absolute_import
58 hgext/largefiles/basestore.py not using absolute_import
56 hgext/largefiles/basestore.py not using absolute_import
59 hgext/largefiles/lfcommands.py not using absolute_import
57 hgext/largefiles/lfcommands.py not using absolute_import
60 hgext/largefiles/lfutil.py not using absolute_import
58 hgext/largefiles/lfutil.py not using absolute_import
61 hgext/largefiles/localstore.py not using absolute_import
59 hgext/largefiles/localstore.py not using absolute_import
62 hgext/largefiles/overrides.py not using absolute_import
60 hgext/largefiles/overrides.py not using absolute_import
63 hgext/largefiles/proto.py not using absolute_import
61 hgext/largefiles/proto.py not using absolute_import
64 hgext/largefiles/remotestore.py not using absolute_import
62 hgext/largefiles/remotestore.py not using absolute_import
65 hgext/largefiles/reposetup.py not using absolute_import
63 hgext/largefiles/reposetup.py not using absolute_import
66 hgext/largefiles/uisetup.py not using absolute_import
64 hgext/largefiles/uisetup.py not using absolute_import
67 hgext/largefiles/wirestore.py not using absolute_import
65 hgext/largefiles/wirestore.py not using absolute_import
68 hgext/mq.py not using absolute_import
66 hgext/mq.py not using absolute_import
69 hgext/notify.py not using absolute_import
67 hgext/notify.py not using absolute_import
70 hgext/patchbomb.py not using absolute_import
68 hgext/patchbomb.py not using absolute_import
71 hgext/purge.py not using absolute_import
69 hgext/purge.py not using absolute_import
72 hgext/rebase.py not using absolute_import
70 hgext/rebase.py not using absolute_import
73 hgext/record.py not using absolute_import
71 hgext/record.py not using absolute_import
74 hgext/relink.py not using absolute_import
72 hgext/relink.py not using absolute_import
75 hgext/schemes.py not using absolute_import
73 hgext/schemes.py not using absolute_import
76 hgext/share.py not using absolute_import
74 hgext/share.py not using absolute_import
77 hgext/shelve.py not using absolute_import
75 hgext/shelve.py not using absolute_import
78 hgext/strip.py not using absolute_import
76 hgext/strip.py not using absolute_import
79 hgext/transplant.py not using absolute_import
77 hgext/transplant.py not using absolute_import
80 hgext/win32mbcs.py not using absolute_import
78 hgext/win32mbcs.py not using absolute_import
81 hgext/win32text.py not using absolute_import
79 hgext/win32text.py not using absolute_import
82 i18n/check-translation.py not using absolute_import
80 i18n/check-translation.py not using absolute_import
83 i18n/polib.py not using absolute_import
81 i18n/polib.py not using absolute_import
84 setup.py not using absolute_import
82 setup.py not using absolute_import
85 tests/filterpyflakes.py requires print_function
83 tests/filterpyflakes.py requires print_function
86 tests/generate-working-copy-states.py requires print_function
84 tests/generate-working-copy-states.py requires print_function
87 tests/get-with-headers.py requires print_function
85 tests/get-with-headers.py requires print_function
88 tests/heredoctest.py requires print_function
86 tests/heredoctest.py requires print_function
89 tests/hypothesishelpers.py not using absolute_import
87 tests/hypothesishelpers.py not using absolute_import
90 tests/hypothesishelpers.py requires print_function
88 tests/hypothesishelpers.py requires print_function
91 tests/killdaemons.py not using absolute_import
89 tests/killdaemons.py not using absolute_import
92 tests/md5sum.py not using absolute_import
90 tests/md5sum.py not using absolute_import
93 tests/mockblackbox.py not using absolute_import
91 tests/mockblackbox.py not using absolute_import
94 tests/printenv.py not using absolute_import
92 tests/printenv.py not using absolute_import
95 tests/readlink.py not using absolute_import
93 tests/readlink.py not using absolute_import
96 tests/readlink.py requires print_function
94 tests/readlink.py requires print_function
97 tests/revlog-formatv0.py not using absolute_import
95 tests/revlog-formatv0.py not using absolute_import
98 tests/run-tests.py not using absolute_import
96 tests/run-tests.py not using absolute_import
99 tests/seq.py not using absolute_import
97 tests/seq.py not using absolute_import
100 tests/seq.py requires print_function
98 tests/seq.py requires print_function
101 tests/silenttestrunner.py not using absolute_import
99 tests/silenttestrunner.py not using absolute_import
102 tests/silenttestrunner.py requires print_function
100 tests/silenttestrunner.py requires print_function
103 tests/sitecustomize.py not using absolute_import
101 tests/sitecustomize.py not using absolute_import
104 tests/svn-safe-append.py not using absolute_import
102 tests/svn-safe-append.py not using absolute_import
105 tests/svnxml.py not using absolute_import
103 tests/svnxml.py not using absolute_import
106 tests/test-ancestor.py requires print_function
104 tests/test-ancestor.py requires print_function
107 tests/test-atomictempfile.py not using absolute_import
105 tests/test-atomictempfile.py not using absolute_import
108 tests/test-batching.py not using absolute_import
106 tests/test-batching.py not using absolute_import
109 tests/test-batching.py requires print_function
107 tests/test-batching.py requires print_function
110 tests/test-bdiff.py not using absolute_import
108 tests/test-bdiff.py not using absolute_import
111 tests/test-bdiff.py requires print_function
109 tests/test-bdiff.py requires print_function
112 tests/test-context.py not using absolute_import
110 tests/test-context.py not using absolute_import
113 tests/test-context.py requires print_function
111 tests/test-context.py requires print_function
114 tests/test-demandimport.py not using absolute_import
112 tests/test-demandimport.py not using absolute_import
115 tests/test-demandimport.py requires print_function
113 tests/test-demandimport.py requires print_function
116 tests/test-dispatch.py not using absolute_import
114 tests/test-dispatch.py not using absolute_import
117 tests/test-dispatch.py requires print_function
115 tests/test-dispatch.py requires print_function
118 tests/test-doctest.py not using absolute_import
116 tests/test-doctest.py not using absolute_import
119 tests/test-duplicateoptions.py not using absolute_import
117 tests/test-duplicateoptions.py not using absolute_import
120 tests/test-duplicateoptions.py requires print_function
118 tests/test-duplicateoptions.py requires print_function
121 tests/test-filecache.py not using absolute_import
119 tests/test-filecache.py not using absolute_import
122 tests/test-filecache.py requires print_function
120 tests/test-filecache.py requires print_function
123 tests/test-filelog.py not using absolute_import
121 tests/test-filelog.py not using absolute_import
124 tests/test-filelog.py requires print_function
122 tests/test-filelog.py requires print_function
125 tests/test-hg-parseurl.py not using absolute_import
123 tests/test-hg-parseurl.py not using absolute_import
126 tests/test-hg-parseurl.py requires print_function
124 tests/test-hg-parseurl.py requires print_function
127 tests/test-hgweb-auth.py not using absolute_import
125 tests/test-hgweb-auth.py not using absolute_import
128 tests/test-hgweb-auth.py requires print_function
126 tests/test-hgweb-auth.py requires print_function
129 tests/test-hgwebdir-paths.py not using absolute_import
127 tests/test-hgwebdir-paths.py not using absolute_import
130 tests/test-hybridencode.py not using absolute_import
128 tests/test-hybridencode.py not using absolute_import
131 tests/test-hybridencode.py requires print_function
129 tests/test-hybridencode.py requires print_function
132 tests/test-lrucachedict.py not using absolute_import
130 tests/test-lrucachedict.py not using absolute_import
133 tests/test-lrucachedict.py requires print_function
131 tests/test-lrucachedict.py requires print_function
134 tests/test-manifest.py not using absolute_import
132 tests/test-manifest.py not using absolute_import
135 tests/test-minirst.py not using absolute_import
133 tests/test-minirst.py not using absolute_import
136 tests/test-minirst.py requires print_function
134 tests/test-minirst.py requires print_function
137 tests/test-parseindex2.py not using absolute_import
135 tests/test-parseindex2.py not using absolute_import
138 tests/test-parseindex2.py requires print_function
136 tests/test-parseindex2.py requires print_function
139 tests/test-pathencode.py not using absolute_import
137 tests/test-pathencode.py not using absolute_import
140 tests/test-pathencode.py requires print_function
138 tests/test-pathencode.py requires print_function
141 tests/test-propertycache.py not using absolute_import
139 tests/test-propertycache.py not using absolute_import
142 tests/test-propertycache.py requires print_function
140 tests/test-propertycache.py requires print_function
143 tests/test-revlog-ancestry.py not using absolute_import
141 tests/test-revlog-ancestry.py not using absolute_import
144 tests/test-revlog-ancestry.py requires print_function
142 tests/test-revlog-ancestry.py requires print_function
145 tests/test-run-tests.py not using absolute_import
143 tests/test-run-tests.py not using absolute_import
146 tests/test-simplemerge.py not using absolute_import
144 tests/test-simplemerge.py not using absolute_import
147 tests/test-status-inprocess.py not using absolute_import
145 tests/test-status-inprocess.py not using absolute_import
148 tests/test-status-inprocess.py requires print_function
146 tests/test-status-inprocess.py requires print_function
149 tests/test-symlink-os-yes-fs-no.py not using absolute_import
147 tests/test-symlink-os-yes-fs-no.py not using absolute_import
150 tests/test-trusted.py not using absolute_import
148 tests/test-trusted.py not using absolute_import
151 tests/test-trusted.py requires print_function
149 tests/test-trusted.py requires print_function
152 tests/test-ui-color.py not using absolute_import
150 tests/test-ui-color.py not using absolute_import
153 tests/test-ui-color.py requires print_function
151 tests/test-ui-color.py requires print_function
154 tests/test-ui-config.py not using absolute_import
152 tests/test-ui-config.py not using absolute_import
155 tests/test-ui-config.py requires print_function
153 tests/test-ui-config.py requires print_function
156 tests/test-ui-verbosity.py not using absolute_import
154 tests/test-ui-verbosity.py not using absolute_import
157 tests/test-ui-verbosity.py requires print_function
155 tests/test-ui-verbosity.py requires print_function
158 tests/test-url.py not using absolute_import
156 tests/test-url.py not using absolute_import
159 tests/test-url.py requires print_function
157 tests/test-url.py requires print_function
160 tests/test-walkrepo.py requires print_function
158 tests/test-walkrepo.py requires print_function
161 tests/test-wireproto.py requires print_function
159 tests/test-wireproto.py requires print_function
162 tests/tinyproxy.py requires print_function
160 tests/tinyproxy.py requires print_function
General Comments 0
You need to be logged in to leave comments. Login now