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