##// END OF EJS Templates
declare local constants instead of using magic values and comments
Mads Kiilerich -
r17429:72fa4ef2 default
parent child Browse files
Show More
@@ -13,6 +13,10 b' import scmutil, util, encoding'
13 import cStringIO, os, tarfile, time, zipfile
13 import cStringIO, os, tarfile, time, zipfile
14 import zlib, gzip
14 import zlib, gzip
15
15
16 # from unzip source code:
17 _UNX_IFREG = 0x8000
18 _UNX_IFLNK = 0xa000
19
16 def tidyprefix(dest, kind, prefix):
20 def tidyprefix(dest, kind, prefix):
17 '''choose prefix to use for names in archive. make sure prefix is
21 '''choose prefix to use for names in archive. make sure prefix is
18 safe for consumers.'''
22 safe for consumers.'''
@@ -173,10 +177,10 b' class zipit(object):'
173 # unzip will not honor unix file modes unless file creator is
177 # unzip will not honor unix file modes unless file creator is
174 # set to unix (id 3).
178 # set to unix (id 3).
175 i.create_system = 3
179 i.create_system = 3
176 ftype = 0x8000 # UNX_IFREG in unzip source code
180 ftype = _UNX_IFREG
177 if islink:
181 if islink:
178 mode = 0777
182 mode = 0777
179 ftype = 0xa000 # UNX_IFLNK in unzip source code
183 ftype = _UNX_IFLNK
180 i.external_attr = (mode | ftype) << 16L
184 i.external_attr = (mode | ftype) << 16L
181 self.z.writestr(i, data)
185 self.z.writestr(i, data)
182
186
@@ -58,6 +58,8 b' from i18n import _'
58 _pack = struct.pack
58 _pack = struct.pack
59 _unpack = struct.unpack
59 _unpack = struct.unpack
60
60
61 _SEEK_END = 2 # os.SEEK_END was introduced in Python 2.5
62
61 # the obsolete feature is not mature enough to be enabled by default.
63 # the obsolete feature is not mature enough to be enabled by default.
62 # you have to rely on third party extension extension to enable this.
64 # you have to rely on third party extension extension to enable this.
63 _enabled = False
65 _enabled = False
@@ -207,7 +209,7 b' class obsstore(object):'
207 # defined. So we must seek to the end before calling tell(),
209 # defined. So we must seek to the end before calling tell(),
208 # or we may get a zero offset for non-zero sized files on
210 # or we may get a zero offset for non-zero sized files on
209 # some platforms (issue3543).
211 # some platforms (issue3543).
210 f.seek(0, 2) # os.SEEK_END
212 f.seek(0, _SEEK_END)
211 offset = f.tell()
213 offset = f.tell()
212 transaction.add('obsstore', offset)
214 transaction.add('obsstore', offset)
213 # offset == 0: new file - add the version header
215 # offset == 0: new file - add the version header
@@ -82,7 +82,7 b' else:'
82
82
83 _FILE_ATTRIBUTE_NORMAL = 0x80
83 _FILE_ATTRIBUTE_NORMAL = 0x80
84
84
85 # _open_osfhandle
85 # open_osfhandle flags
86 _O_RDONLY = 0x0000
86 _O_RDONLY = 0x0000
87 _O_RDWR = 0x0002
87 _O_RDWR = 0x0002
88 _O_APPEND = 0x0008
88 _O_APPEND = 0x0008
General Comments 0
You need to be logged in to leave comments. Login now