tests/hghave.py
changeset 25658 e93036747902
parent 25413 4d705f6a3c35
child 25859 1619563959b3
equal deleted inserted replaced
25657:dcc56e10c23b 25658:e93036747902
    86     try:
    86     try:
    87         EXECFLAGS = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
    87         EXECFLAGS = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
    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):
    98         # we don't care, the user probably won't be able to commit anyway
    98         # we don't care, the user probably won't be able to commit anyway
    99         return False
    99         return False
   244 @check("unix-permissions", "unix-style permissions")
   244 @check("unix-permissions", "unix-style permissions")
   245 def has_unix_permissions():
   245 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:
   259         os.rmdir(d)
   259         os.rmdir(d)
   260 
   260