Show More
@@ -201,7 +201,7 b' class darcs_source(converter_source, com' | |||||
201 | if inst.errno == errno.ENOENT: |
|
201 | if inst.errno == errno.ENOENT: | |
202 | return None, None |
|
202 | return None, None | |
203 | raise |
|
203 | raise | |
204 | mode = (mode & 0111) and 'x' or '' |
|
204 | mode = (mode & 0o111) and 'x' or '' | |
205 | return data, mode |
|
205 | return data, mode | |
206 |
|
206 | |||
207 | def gettags(self): |
|
207 | def gettags(self): |
@@ -215,7 +215,7 b' class gnuarch_source(converter_source, c' | |||||
215 | mode = '' |
|
215 | mode = '' | |
216 | else: |
|
216 | else: | |
217 | data = open(os.path.join(self.tmppath, name), 'rb').read() |
|
217 | data = open(os.path.join(self.tmppath, name), 'rb').read() | |
218 | mode = (mode & 0111) and 'x' or '' |
|
218 | mode = (mode & 0o111) and 'x' or '' | |
219 | return data, mode |
|
219 | return data, mode | |
220 |
|
220 | |||
221 | def _exclude(self, name): |
|
221 | def _exclude(self, name): |
@@ -908,7 +908,7 b' def overridearchive(orig, repo, dest, no' | |||||
908 | archiver = archival.archivers[kind](dest, mtime or ctx.date()[0]) |
|
908 | archiver = archival.archivers[kind](dest, mtime or ctx.date()[0]) | |
909 |
|
909 | |||
910 | if repo.ui.configbool("ui", "archivemeta", True): |
|
910 | if repo.ui.configbool("ui", "archivemeta", True): | |
911 | write('.hg_archival.txt', 0644, False, |
|
911 | write('.hg_archival.txt', 0o644, False, | |
912 | lambda: archival.buildmetadata(ctx)) |
|
912 | lambda: archival.buildmetadata(ctx)) | |
913 |
|
913 | |||
914 | for f in ctx: |
|
914 | for f in ctx: | |
@@ -937,7 +937,7 b' def overridearchive(orig, repo, dest, no' | |||||
937 | fd.close() |
|
937 | fd.close() | |
938 |
|
938 | |||
939 | getdata = getdatafn |
|
939 | getdata = getdatafn | |
940 | write(f, 'x' in ff and 0755 or 0644, 'l' in ff, getdata) |
|
940 | write(f, 'x' in ff and 0o755 or 0o644, 'l' in ff, getdata) | |
941 |
|
941 | |||
942 | if subrepos: |
|
942 | if subrepos: | |
943 | for subpath in sorted(ctx.substate): |
|
943 | for subpath in sorted(ctx.substate): | |
@@ -991,7 +991,7 b' def hgsubrepoarchive(orig, repo, archive' | |||||
991 |
|
991 | |||
992 | getdata = getdatafn |
|
992 | getdata = getdatafn | |
993 |
|
993 | |||
994 | write(f, 'x' in ff and 0755 or 0644, 'l' in ff, getdata) |
|
994 | write(f, 'x' in ff and 0o755 or 0o644, 'l' in ff, getdata) | |
995 |
|
995 | |||
996 | for subpath in sorted(ctx.substate): |
|
996 | for subpath in sorted(ctx.substate): | |
997 | sub = ctx.workingsub(subpath) |
|
997 | sub = ctx.workingsub(subpath) |
@@ -157,7 +157,7 b' class tarit(object):' | |||||
157 | i.size = len(data) |
|
157 | i.size = len(data) | |
158 | if islink: |
|
158 | if islink: | |
159 | i.type = tarfile.SYMTYPE |
|
159 | i.type = tarfile.SYMTYPE | |
160 | i.mode = 0777 |
|
160 | i.mode = 0o777 | |
161 | i.linkname = data |
|
161 | i.linkname = data | |
162 | data = None |
|
162 | data = None | |
163 | i.size = 0 |
|
163 | i.size = 0 | |
@@ -220,7 +220,7 b' class zipit(object):' | |||||
220 | i.create_system = 3 |
|
220 | i.create_system = 3 | |
221 | ftype = _UNX_IFREG |
|
221 | ftype = _UNX_IFREG | |
222 | if islink: |
|
222 | if islink: | |
223 | mode = 0777 |
|
223 | mode = 0o777 | |
224 | ftype = _UNX_IFLNK |
|
224 | ftype = _UNX_IFLNK | |
225 | i.external_attr = (mode | ftype) << 16L |
|
225 | i.external_attr = (mode | ftype) << 16L | |
226 | # add "extended-timestamp" extra block, because zip archives |
|
226 | # add "extended-timestamp" extra block, because zip archives | |
@@ -302,7 +302,7 b' def archive(repo, dest, node, kind, deco' | |||||
302 | if repo.ui.configbool("ui", "archivemeta", True): |
|
302 | if repo.ui.configbool("ui", "archivemeta", True): | |
303 | name = '.hg_archival.txt' |
|
303 | name = '.hg_archival.txt' | |
304 | if not matchfn or matchfn(name): |
|
304 | if not matchfn or matchfn(name): | |
305 | write(name, 0644, False, lambda: buildmetadata(ctx)) |
|
305 | write(name, 0o644, False, lambda: buildmetadata(ctx)) | |
306 |
|
306 | |||
307 | if matchfn: |
|
307 | if matchfn: | |
308 | files = [f for f in ctx.manifest().keys() if matchfn(f)] |
|
308 | files = [f for f in ctx.manifest().keys() if matchfn(f)] | |
@@ -314,7 +314,7 b' def archive(repo, dest, node, kind, deco' | |||||
314 | repo.ui.progress(_('archiving'), 0, unit=_('files'), total=total) |
|
314 | repo.ui.progress(_('archiving'), 0, unit=_('files'), total=total) | |
315 | for i, f in enumerate(files): |
|
315 | for i, f in enumerate(files): | |
316 | ff = ctx.flags(f) |
|
316 | ff = ctx.flags(f) | |
317 | write(f, 'x' in ff and 0755 or 0644, 'l' in ff, ctx[f].data) |
|
317 | write(f, 'x' in ff and 0o755 or 0o644, 'l' in ff, ctx[f].data) | |
318 | repo.ui.progress(_('archiving'), i + 1, item=f, |
|
318 | repo.ui.progress(_('archiving'), i + 1, item=f, | |
319 | unit=_('files'), total=total) |
|
319 | unit=_('files'), total=total) | |
320 | repo.ui.progress(_('archiving'), None) |
|
320 | repo.ui.progress(_('archiving'), None) |
@@ -3001,10 +3001,10 b' def debugstate(ui, repo, nodates=None, d' | |||||
3001 | else: |
|
3001 | else: | |
3002 | timestr = time.strftime("%Y-%m-%d %H:%M:%S ", |
|
3002 | timestr = time.strftime("%Y-%m-%d %H:%M:%S ", | |
3003 | time.localtime(ent[3])) |
|
3003 | time.localtime(ent[3])) | |
3004 | if ent[1] & 020000: |
|
3004 | if ent[1] & 0o20000: | |
3005 | mode = 'lnk' |
|
3005 | mode = 'lnk' | |
3006 | else: |
|
3006 | else: | |
3007 | mode = '%3o' % (ent[1] & 0777 & ~util.umask) |
|
3007 | mode = '%3o' % (ent[1] & 0o777 & ~util.umask) | |
3008 | ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_)) |
|
3008 | ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_)) | |
3009 | for f in repo.dirstate.copies(): |
|
3009 | for f in repo.dirstate.copies(): | |
3010 | ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f)) |
|
3010 | ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f)) |
@@ -594,9 +594,9 b' class dirstate(object):' | |||||
594 | self._map[f] = oldmap[f] |
|
594 | self._map[f] = oldmap[f] | |
595 | else: |
|
595 | else: | |
596 | if 'x' in allfiles.flags(f): |
|
596 | if 'x' in allfiles.flags(f): | |
597 | self._map[f] = dirstatetuple('n', 0777, -1, 0) |
|
597 | self._map[f] = dirstatetuple('n', 0o777, -1, 0) | |
598 | else: |
|
598 | else: | |
599 | self._map[f] = dirstatetuple('n', 0666, -1, 0) |
|
599 | self._map[f] = dirstatetuple('n', 0o666, -1, 0) | |
600 | self._pl = (parent, nullid) |
|
600 | self._pl = (parent, nullid) | |
601 | self._dirty = True |
|
601 | self._dirty = True | |
602 |
|
602 | |||
@@ -963,7 +963,7 b' class dirstate(object):' | |||||
963 | mtime = int(st.st_mtime) |
|
963 | mtime = int(st.st_mtime) | |
964 | if (size >= 0 and |
|
964 | if (size >= 0 and | |
965 | ((size != st.st_size and size != st.st_size & _rangemask) |
|
965 | ((size != st.st_size and size != st.st_size & _rangemask) | |
966 | or ((mode ^ st.st_mode) & 0100 and checkexec)) |
|
966 | or ((mode ^ st.st_mode) & 0o100 and checkexec)) | |
967 | or size == -2 # other parent |
|
967 | or size == -2 # other parent | |
968 | or fn in copymap): |
|
968 | or fn in copymap): | |
969 | madd(fn) |
|
969 | madd(fn) |
@@ -288,8 +288,8 b' class patchmeta(object):' | |||||
288 | self.binary = False |
|
288 | self.binary = False | |
289 |
|
289 | |||
290 | def setmode(self, mode): |
|
290 | def setmode(self, mode): | |
291 | islink = mode & 020000 |
|
291 | islink = mode & 0o20000 | |
292 | isexec = mode & 0100 |
|
292 | isexec = mode & 0o100 | |
293 | self.mode = (islink, isexec) |
|
293 | self.mode = (islink, isexec) | |
294 |
|
294 | |||
295 | def copy(self): |
|
295 | def copy(self): | |
@@ -430,7 +430,7 b' class fsbackend(abstractbackend):' | |||||
430 |
|
430 | |||
431 | isexec = False |
|
431 | isexec = False | |
432 | try: |
|
432 | try: | |
433 | isexec = self.opener.lstat(fname).st_mode & 0100 != 0 |
|
433 | isexec = self.opener.lstat(fname).st_mode & 0o100 != 0 | |
434 | except OSError, e: |
|
434 | except OSError, e: | |
435 | if e.errno != errno.ENOENT: |
|
435 | if e.errno != errno.ENOENT: | |
436 | raise |
|
436 | raise |
@@ -71,7 +71,7 b' def sshargs(sshcmd, host, user, port):' | |||||
71 |
|
71 | |||
72 | def isexec(f): |
|
72 | def isexec(f): | |
73 | """check whether a file is executable""" |
|
73 | """check whether a file is executable""" | |
74 | return (os.lstat(f).st_mode & 0100 != 0) |
|
74 | return (os.lstat(f).st_mode & 0o100 != 0) | |
75 |
|
75 | |||
76 | def setflags(f, l, x): |
|
76 | def setflags(f, l, x): | |
77 | s = os.lstat(f).st_mode |
|
77 | s = os.lstat(f).st_mode | |
@@ -98,30 +98,30 b' def setflags(f, l, x):' | |||||
98 | fp = open(f, "w") |
|
98 | fp = open(f, "w") | |
99 | fp.write(data) |
|
99 | fp.write(data) | |
100 | fp.close() |
|
100 | fp.close() | |
101 | s = 0666 & ~umask # avoid restatting for chmod |
|
101 | s = 0o666 & ~umask # avoid restatting for chmod | |
102 |
|
102 | |||
103 | sx = s & 0100 |
|
103 | sx = s & 0o100 | |
104 | if x and not sx: |
|
104 | if x and not sx: | |
105 | # Turn on +x for every +r bit when making a file executable |
|
105 | # Turn on +x for every +r bit when making a file executable | |
106 | # and obey umask. |
|
106 | # and obey umask. | |
107 | os.chmod(f, s | (s & 0444) >> 2 & ~umask) |
|
107 | os.chmod(f, s | (s & 0o444) >> 2 & ~umask) | |
108 | elif not x and sx: |
|
108 | elif not x and sx: | |
109 | # Turn off all +x bits |
|
109 | # Turn off all +x bits | |
110 | os.chmod(f, s & 0666) |
|
110 | os.chmod(f, s & 0o666) | |
111 |
|
111 | |||
112 | def copymode(src, dst, mode=None): |
|
112 | def copymode(src, dst, mode=None): | |
113 | '''Copy the file mode from the file at path src to dst. |
|
113 | '''Copy the file mode from the file at path src to dst. | |
114 | If src doesn't exist, we're using mode instead. If mode is None, we're |
|
114 | If src doesn't exist, we're using mode instead. If mode is None, we're | |
115 | using umask.''' |
|
115 | using umask.''' | |
116 | try: |
|
116 | try: | |
117 | st_mode = os.lstat(src).st_mode & 0777 |
|
117 | st_mode = os.lstat(src).st_mode & 0o777 | |
118 | except OSError, inst: |
|
118 | except OSError, inst: | |
119 | if inst.errno != errno.ENOENT: |
|
119 | if inst.errno != errno.ENOENT: | |
120 | raise |
|
120 | raise | |
121 | st_mode = mode |
|
121 | st_mode = mode | |
122 | if st_mode is None: |
|
122 | if st_mode is None: | |
123 | st_mode = ~umask |
|
123 | st_mode = ~umask | |
124 | st_mode &= 0666 |
|
124 | st_mode &= 0o666 | |
125 | os.chmod(dst, st_mode) |
|
125 | os.chmod(dst, st_mode) | |
126 |
|
126 | |||
127 | def checkexec(path): |
|
127 | def checkexec(path): | |
@@ -140,10 +140,10 b' def checkexec(path):' | |||||
140 | fh, fn = tempfile.mkstemp(dir=path, prefix='hg-checkexec-') |
|
140 | fh, fn = tempfile.mkstemp(dir=path, prefix='hg-checkexec-') | |
141 | try: |
|
141 | try: | |
142 | os.close(fh) |
|
142 | os.close(fh) | |
143 | m = os.stat(fn).st_mode & 0777 |
|
143 | m = os.stat(fn).st_mode & 0o777 | |
144 | new_file_has_exec = m & EXECFLAGS |
|
144 | new_file_has_exec = m & EXECFLAGS | |
145 | os.chmod(fn, m ^ EXECFLAGS) |
|
145 | os.chmod(fn, m ^ EXECFLAGS) | |
146 | exec_flags_cannot_flip = ((os.stat(fn).st_mode & 0777) == m) |
|
146 | exec_flags_cannot_flip = ((os.stat(fn).st_mode & 0o777) == m) | |
147 | finally: |
|
147 | finally: | |
148 | os.unlink(fn) |
|
148 | os.unlink(fn) | |
149 | except (IOError, OSError): |
|
149 | except (IOError, OSError): | |
@@ -593,7 +593,7 b' def statislink(st):' | |||||
593 |
|
593 | |||
594 | def statisexec(st): |
|
594 | def statisexec(st): | |
595 | '''check whether a stat result is an executable file''' |
|
595 | '''check whether a stat result is an executable file''' | |
596 | return st and (st.st_mode & 0100 != 0) |
|
596 | return st and (st.st_mode & 0o100 != 0) | |
597 |
|
597 | |||
598 | def poll(fds): |
|
598 | def poll(fds): | |
599 | """block until something happens on any file descriptor |
|
599 | """block until something happens on any file descriptor |
@@ -450,7 +450,7 b' class vfs(abstractvfs):' | |||||
450 | def _fixfilemode(self, name): |
|
450 | def _fixfilemode(self, name): | |
451 | if self.createmode is None or not self._chmod: |
|
451 | if self.createmode is None or not self._chmod: | |
452 | return |
|
452 | return | |
453 | os.chmod(name, self.createmode & 0666) |
|
453 | os.chmod(name, self.createmode & 0o666) | |
454 |
|
454 | |||
455 | def __call__(self, path, mode="r", text=False, atomictemp=False, |
|
455 | def __call__(self, path, mode="r", text=False, atomictemp=False, | |
456 | notindexed=False): |
|
456 | notindexed=False): |
@@ -274,7 +274,7 b' def _calcmode(vfs):' | |||||
274 | # files in .hg/ will be created using this mode |
|
274 | # files in .hg/ will be created using this mode | |
275 | mode = vfs.stat().st_mode |
|
275 | mode = vfs.stat().st_mode | |
276 | # avoid some useless chmods |
|
276 | # avoid some useless chmods | |
277 | if (0777 & ~util.umask) == (0777 & mode): |
|
277 | if (0o777 & ~util.umask) == (0o777 & mode): | |
278 | mode = None |
|
278 | mode = None | |
279 | except OSError: |
|
279 | except OSError: | |
280 | mode = None |
|
280 | mode = None |
@@ -540,7 +540,7 b' class abstractsubrepo(object):' | |||||
540 | unit=_('files'), total=total) |
|
540 | unit=_('files'), total=total) | |
541 | for i, name in enumerate(files): |
|
541 | for i, name in enumerate(files): | |
542 | flags = self.fileflags(name) |
|
542 | flags = self.fileflags(name) | |
543 | mode = 'x' in flags and 0755 or 0644 |
|
543 | mode = 'x' in flags and 0o755 or 0o644 | |
544 | symlink = 'l' in flags |
|
544 | symlink = 'l' in flags | |
545 | archiver.addfile(prefix + self._path + '/' + name, |
|
545 | archiver.addfile(prefix + self._path + '/' + name, | |
546 | mode, symlink, self.filedata(name)) |
|
546 | mode, symlink, self.filedata(name)) |
@@ -130,8 +130,8 b' class transaction(object):' | |||||
130 | self._backupsfile.write('%d\n' % version) |
|
130 | self._backupsfile.write('%d\n' % version) | |
131 |
|
131 | |||
132 | if createmode is not None: |
|
132 | if createmode is not None: | |
133 | opener.chmod(self.journal, createmode & 0666) |
|
133 | opener.chmod(self.journal, createmode & 0o666) | |
134 | opener.chmod(self._backupjournal, createmode & 0666) |
|
134 | opener.chmod(self._backupjournal, createmode & 0o666) | |
135 |
|
135 | |||
136 | # hold file generations to be performed on commit |
|
136 | # hold file generations to be performed on commit | |
137 | self._filegenerators = {} |
|
137 | self._filegenerators = {} |
@@ -25,7 +25,7 b' termwidth = win32.termwidth' | |||||
25 | testpid = win32.testpid |
|
25 | testpid = win32.testpid | |
26 | unlink = win32.unlink |
|
26 | unlink = win32.unlink | |
27 |
|
27 | |||
28 | umask = 0022 |
|
28 | umask = 0o022 | |
29 |
|
29 | |||
30 | def posixfile(name, mode='r', buffering=-1): |
|
30 | def posixfile(name, mode='r', buffering=-1): | |
31 | '''Open a file with even more POSIX-like semantics''' |
|
31 | '''Open a file with even more POSIX-like semantics''' |
@@ -88,10 +88,10 b' def has_executablebit():' | |||||
88 | fh, fn = tempfile.mkstemp(dir='.', prefix=tempprefix) |
|
88 | fh, fn = tempfile.mkstemp(dir='.', prefix=tempprefix) | |
89 | try: |
|
89 | try: | |
90 | os.close(fh) |
|
90 | os.close(fh) | |
91 | m = os.stat(fn).st_mode & 0777 |
|
91 | m = os.stat(fn).st_mode & 0o777 | |
92 | new_file_has_exec = m & EXECFLAGS |
|
92 | new_file_has_exec = m & EXECFLAGS | |
93 | os.chmod(fn, m ^ EXECFLAGS) |
|
93 | os.chmod(fn, m ^ EXECFLAGS) | |
94 | exec_flags_cannot_flip = ((os.stat(fn).st_mode & 0777) == m) |
|
94 | exec_flags_cannot_flip = ((os.stat(fn).st_mode & 0o777) == m) | |
95 | finally: |
|
95 | finally: | |
96 | os.unlink(fn) |
|
96 | os.unlink(fn) | |
97 | except (IOError, OSError): |
|
97 | except (IOError, OSError): | |
@@ -246,13 +246,13 b' def has_unix_permissions():' | |||||
246 | d = tempfile.mkdtemp(dir='.', prefix=tempprefix) |
|
246 | d = tempfile.mkdtemp(dir='.', prefix=tempprefix) | |
247 | try: |
|
247 | try: | |
248 | fname = os.path.join(d, 'foo') |
|
248 | fname = os.path.join(d, 'foo') | |
249 | for umask in (077, 007, 022): |
|
249 | for umask in (0o77, 0o07, 0o22): | |
250 | os.umask(umask) |
|
250 | os.umask(umask) | |
251 | f = open(fname, 'w') |
|
251 | f = open(fname, 'w') | |
252 | f.close() |
|
252 | f.close() | |
253 | mode = os.stat(fname).st_mode |
|
253 | mode = os.stat(fname).st_mode | |
254 | os.unlink(fname) |
|
254 | os.unlink(fname) | |
255 | if mode & 0777 != ~umask & 0666: |
|
255 | if mode & 0o777 != ~umask & 0o666: | |
256 | return False |
|
256 | return False | |
257 | return True |
|
257 | return True | |
258 | finally: |
|
258 | finally: |
General Comments 0
You need to be logged in to leave comments.
Login now