hghave: detect unix-style permissions
authorAlexis S. L. Carvalho <alexis@cecm.usp.br>
Sat, 09 Feb 2008 18:38:54 -0200
changeset 6063 b74a0c4bfb30
parent 6062 3c3b126e5619
child 6064 c608f67a87c0
hghave: detect unix-style permissions By "unix-style" I mean: - user/group/other permissions - umask determines original permissions
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():