Mercurial > hg-stable
changeset 25658:e93036747902
global: mass rewrite to use modern octal syntax
Python 2.6 introduced a new octal syntax: "0oXXX", replacing "0XXX". The
old syntax is not recognized in Python 3 and will result in a parse
error.
Mass rewrite all instances of the old octal syntax to the new syntax.
This patch was generated by `2to3 -f numliterals -w -n .` and the diff
was selectively recorded to exclude changes to "<N>l" syntax conversion,
which will be handled separately.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 23 Jun 2015 22:30:33 -0700 |
parents | dcc56e10c23b |
children | d60678a567a9 |
files | hgext/convert/darcs.py hgext/convert/gnuarch.py hgext/largefiles/overrides.py mercurial/archival.py mercurial/commands.py mercurial/dirstate.py mercurial/patch.py mercurial/posix.py mercurial/scmutil.py mercurial/store.py mercurial/subrepo.py mercurial/transaction.py mercurial/windows.py tests/hghave.py |
diffstat | 14 files changed, 37 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/convert/darcs.py Tue Jun 23 14:28:15 2015 -0700 +++ b/hgext/convert/darcs.py Tue Jun 23 22:30:33 2015 -0700 @@ -201,7 +201,7 @@ if inst.errno == errno.ENOENT: return None, None raise - mode = (mode & 0111) and 'x' or '' + mode = (mode & 0o111) and 'x' or '' return data, mode def gettags(self):
--- a/hgext/convert/gnuarch.py Tue Jun 23 14:28:15 2015 -0700 +++ b/hgext/convert/gnuarch.py Tue Jun 23 22:30:33 2015 -0700 @@ -215,7 +215,7 @@ mode = '' else: data = open(os.path.join(self.tmppath, name), 'rb').read() - mode = (mode & 0111) and 'x' or '' + mode = (mode & 0o111) and 'x' or '' return data, mode def _exclude(self, name):
--- a/hgext/largefiles/overrides.py Tue Jun 23 14:28:15 2015 -0700 +++ b/hgext/largefiles/overrides.py Tue Jun 23 22:30:33 2015 -0700 @@ -908,7 +908,7 @@ archiver = archival.archivers[kind](dest, mtime or ctx.date()[0]) if repo.ui.configbool("ui", "archivemeta", True): - write('.hg_archival.txt', 0644, False, + write('.hg_archival.txt', 0o644, False, lambda: archival.buildmetadata(ctx)) for f in ctx: @@ -937,7 +937,7 @@ fd.close() getdata = getdatafn - write(f, 'x' in ff and 0755 or 0644, 'l' in ff, getdata) + write(f, 'x' in ff and 0o755 or 0o644, 'l' in ff, getdata) if subrepos: for subpath in sorted(ctx.substate): @@ -991,7 +991,7 @@ getdata = getdatafn - write(f, 'x' in ff and 0755 or 0644, 'l' in ff, getdata) + write(f, 'x' in ff and 0o755 or 0o644, 'l' in ff, getdata) for subpath in sorted(ctx.substate): sub = ctx.workingsub(subpath)
--- a/mercurial/archival.py Tue Jun 23 14:28:15 2015 -0700 +++ b/mercurial/archival.py Tue Jun 23 22:30:33 2015 -0700 @@ -157,7 +157,7 @@ i.size = len(data) if islink: i.type = tarfile.SYMTYPE - i.mode = 0777 + i.mode = 0o777 i.linkname = data data = None i.size = 0 @@ -220,7 +220,7 @@ i.create_system = 3 ftype = _UNX_IFREG if islink: - mode = 0777 + mode = 0o777 ftype = _UNX_IFLNK i.external_attr = (mode | ftype) << 16L # add "extended-timestamp" extra block, because zip archives @@ -302,7 +302,7 @@ if repo.ui.configbool("ui", "archivemeta", True): name = '.hg_archival.txt' if not matchfn or matchfn(name): - write(name, 0644, False, lambda: buildmetadata(ctx)) + write(name, 0o644, False, lambda: buildmetadata(ctx)) if matchfn: files = [f for f in ctx.manifest().keys() if matchfn(f)] @@ -314,7 +314,7 @@ repo.ui.progress(_('archiving'), 0, unit=_('files'), total=total) for i, f in enumerate(files): ff = ctx.flags(f) - write(f, 'x' in ff and 0755 or 0644, 'l' in ff, ctx[f].data) + write(f, 'x' in ff and 0o755 or 0o644, 'l' in ff, ctx[f].data) repo.ui.progress(_('archiving'), i + 1, item=f, unit=_('files'), total=total) repo.ui.progress(_('archiving'), None)
--- a/mercurial/commands.py Tue Jun 23 14:28:15 2015 -0700 +++ b/mercurial/commands.py Tue Jun 23 22:30:33 2015 -0700 @@ -3001,10 +3001,10 @@ else: timestr = time.strftime("%Y-%m-%d %H:%M:%S ", time.localtime(ent[3])) - if ent[1] & 020000: + if ent[1] & 0o20000: mode = 'lnk' else: - mode = '%3o' % (ent[1] & 0777 & ~util.umask) + mode = '%3o' % (ent[1] & 0o777 & ~util.umask) ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_)) for f in repo.dirstate.copies(): ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
--- a/mercurial/dirstate.py Tue Jun 23 14:28:15 2015 -0700 +++ b/mercurial/dirstate.py Tue Jun 23 22:30:33 2015 -0700 @@ -594,9 +594,9 @@ self._map[f] = oldmap[f] else: if 'x' in allfiles.flags(f): - self._map[f] = dirstatetuple('n', 0777, -1, 0) + self._map[f] = dirstatetuple('n', 0o777, -1, 0) else: - self._map[f] = dirstatetuple('n', 0666, -1, 0) + self._map[f] = dirstatetuple('n', 0o666, -1, 0) self._pl = (parent, nullid) self._dirty = True @@ -963,7 +963,7 @@ mtime = int(st.st_mtime) if (size >= 0 and ((size != st.st_size and size != st.st_size & _rangemask) - or ((mode ^ st.st_mode) & 0100 and checkexec)) + or ((mode ^ st.st_mode) & 0o100 and checkexec)) or size == -2 # other parent or fn in copymap): madd(fn)
--- a/mercurial/patch.py Tue Jun 23 14:28:15 2015 -0700 +++ b/mercurial/patch.py Tue Jun 23 22:30:33 2015 -0700 @@ -288,8 +288,8 @@ self.binary = False def setmode(self, mode): - islink = mode & 020000 - isexec = mode & 0100 + islink = mode & 0o20000 + isexec = mode & 0o100 self.mode = (islink, isexec) def copy(self): @@ -430,7 +430,7 @@ isexec = False try: - isexec = self.opener.lstat(fname).st_mode & 0100 != 0 + isexec = self.opener.lstat(fname).st_mode & 0o100 != 0 except OSError, e: if e.errno != errno.ENOENT: raise
--- a/mercurial/posix.py Tue Jun 23 14:28:15 2015 -0700 +++ b/mercurial/posix.py Tue Jun 23 22:30:33 2015 -0700 @@ -71,7 +71,7 @@ def isexec(f): """check whether a file is executable""" - return (os.lstat(f).st_mode & 0100 != 0) + return (os.lstat(f).st_mode & 0o100 != 0) def setflags(f, l, x): s = os.lstat(f).st_mode @@ -98,30 +98,30 @@ fp = open(f, "w") fp.write(data) fp.close() - s = 0666 & ~umask # avoid restatting for chmod + s = 0o666 & ~umask # avoid restatting for chmod - sx = s & 0100 + sx = s & 0o100 if x and not sx: # Turn on +x for every +r bit when making a file executable # and obey umask. - os.chmod(f, s | (s & 0444) >> 2 & ~umask) + os.chmod(f, s | (s & 0o444) >> 2 & ~umask) elif not x and sx: # Turn off all +x bits - os.chmod(f, s & 0666) + os.chmod(f, s & 0o666) def copymode(src, dst, mode=None): '''Copy the file mode from the file at path src to dst. If src doesn't exist, we're using mode instead. If mode is None, we're using umask.''' try: - st_mode = os.lstat(src).st_mode & 0777 + st_mode = os.lstat(src).st_mode & 0o777 except OSError, inst: if inst.errno != errno.ENOENT: raise st_mode = mode if st_mode is None: st_mode = ~umask - st_mode &= 0666 + st_mode &= 0o666 os.chmod(dst, st_mode) def checkexec(path): @@ -140,10 +140,10 @@ fh, fn = tempfile.mkstemp(dir=path, prefix='hg-checkexec-') try: os.close(fh) - m = os.stat(fn).st_mode & 0777 + m = os.stat(fn).st_mode & 0o777 new_file_has_exec = m & EXECFLAGS os.chmod(fn, m ^ EXECFLAGS) - exec_flags_cannot_flip = ((os.stat(fn).st_mode & 0777) == m) + exec_flags_cannot_flip = ((os.stat(fn).st_mode & 0o777) == m) finally: os.unlink(fn) except (IOError, OSError): @@ -593,7 +593,7 @@ def statisexec(st): '''check whether a stat result is an executable file''' - return st and (st.st_mode & 0100 != 0) + return st and (st.st_mode & 0o100 != 0) def poll(fds): """block until something happens on any file descriptor
--- a/mercurial/scmutil.py Tue Jun 23 14:28:15 2015 -0700 +++ b/mercurial/scmutil.py Tue Jun 23 22:30:33 2015 -0700 @@ -450,7 +450,7 @@ def _fixfilemode(self, name): if self.createmode is None or not self._chmod: return - os.chmod(name, self.createmode & 0666) + os.chmod(name, self.createmode & 0o666) def __call__(self, path, mode="r", text=False, atomictemp=False, notindexed=False):
--- a/mercurial/store.py Tue Jun 23 14:28:15 2015 -0700 +++ b/mercurial/store.py Tue Jun 23 22:30:33 2015 -0700 @@ -274,7 +274,7 @@ # files in .hg/ will be created using this mode mode = vfs.stat().st_mode # avoid some useless chmods - if (0777 & ~util.umask) == (0777 & mode): + if (0o777 & ~util.umask) == (0o777 & mode): mode = None except OSError: mode = None
--- a/mercurial/subrepo.py Tue Jun 23 14:28:15 2015 -0700 +++ b/mercurial/subrepo.py Tue Jun 23 22:30:33 2015 -0700 @@ -540,7 +540,7 @@ unit=_('files'), total=total) for i, name in enumerate(files): flags = self.fileflags(name) - mode = 'x' in flags and 0755 or 0644 + mode = 'x' in flags and 0o755 or 0o644 symlink = 'l' in flags archiver.addfile(prefix + self._path + '/' + name, mode, symlink, self.filedata(name))
--- a/mercurial/transaction.py Tue Jun 23 14:28:15 2015 -0700 +++ b/mercurial/transaction.py Tue Jun 23 22:30:33 2015 -0700 @@ -130,8 +130,8 @@ self._backupsfile.write('%d\n' % version) if createmode is not None: - opener.chmod(self.journal, createmode & 0666) - opener.chmod(self._backupjournal, createmode & 0666) + opener.chmod(self.journal, createmode & 0o666) + opener.chmod(self._backupjournal, createmode & 0o666) # hold file generations to be performed on commit self._filegenerators = {}
--- a/mercurial/windows.py Tue Jun 23 14:28:15 2015 -0700 +++ b/mercurial/windows.py Tue Jun 23 22:30:33 2015 -0700 @@ -25,7 +25,7 @@ testpid = win32.testpid unlink = win32.unlink -umask = 0022 +umask = 0o022 def posixfile(name, mode='r', buffering=-1): '''Open a file with even more POSIX-like semantics'''
--- a/tests/hghave.py Tue Jun 23 14:28:15 2015 -0700 +++ b/tests/hghave.py Tue Jun 23 22:30:33 2015 -0700 @@ -88,10 +88,10 @@ fh, fn = tempfile.mkstemp(dir='.', prefix=tempprefix) try: os.close(fh) - m = os.stat(fn).st_mode & 0777 + m = os.stat(fn).st_mode & 0o777 new_file_has_exec = m & EXECFLAGS os.chmod(fn, m ^ EXECFLAGS) - exec_flags_cannot_flip = ((os.stat(fn).st_mode & 0777) == m) + exec_flags_cannot_flip = ((os.stat(fn).st_mode & 0o777) == m) finally: os.unlink(fn) except (IOError, OSError): @@ -246,13 +246,13 @@ d = tempfile.mkdtemp(dir='.', prefix=tempprefix) try: fname = os.path.join(d, 'foo') - for umask in (077, 007, 022): + for umask in (0o77, 0o07, 0o22): os.umask(umask) f = open(fname, 'w') f.close() mode = os.stat(fname).st_mode os.unlink(fname) - if mode & 0777 != ~umask & 0666: + if mode & 0o777 != ~umask & 0o666: return False return True finally: