# HG changeset patch # User Alexis S. L. Carvalho # Date 1202589534 7200 # Node ID b74a0c4bfb3003388aaae66c722e281042c01433 # Parent 3c3b126e561970e5d68ed6d3c9748d6a374782d8 hghave: detect unix-style permissions By "unix-style" I mean: - user/group/other permissions - umask determines original permissions diff -r 3c3b126e5619 -r b74a0c4bfb30 tests/hghave --- a/tests/hghave Sat Feb 09 18:38:54 2008 -0200 +++ b/tests/hghave Sat Feb 09 18:38:54 2008 -0200 @@ -85,6 +85,22 @@ def has_symlink(): return hasattr(os, "symlink") +def has_unix_permissions(): + d = tempfile.mkdtemp(prefix=tempprefix, dir=".") + try: + fname = os.path.join(d, 'foo') + for umask in (077, 007, 022): + os.umask(umask) + f = open(fname, 'w') + f.close() + mode = os.stat(fname).st_mode + os.unlink(fname) + if mode & 0777 != ~umask & 0666: + return False + return True + finally: + os.rmdir(d) + checks = { "cvs": (has_cvs, "cvs client"), "cvsps": (has_cvsps, "cvsps utility"), @@ -98,6 +114,7 @@ "svn": (has_svn, "subversion client and admin tools"), "svn-bindings": (has_svn_bindings, "subversion python bindings"), "symlink": (has_symlink, "symbolic links"), + "unix-permissions": (has_unix_permissions, "unix-style permissions"), } def list_features():