exec: checkexec checks whether filesystem supports exec flags
authorMatt Mackall <mpm@selenic.com>
Fri, 29 Dec 2006 20:04:30 -0600
changeset 3994 1cc60eebc71f
parent 3993 04d919cdf263
child 3995 a4e79f86d304
exec: checkexec checks whether filesystem supports exec flags
mercurial/util.py
--- a/mercurial/util.py	Tue Dec 26 20:08:09 2006 +0100
+++ b/mercurial/util.py	Fri Dec 29 20:04:30 2006 -0600
@@ -693,6 +693,20 @@
     except:
         return True
 
+def checkexec(path):
+    """
+    Check whether the given path is on a filesystem with UNIX-like exec flags
+
+    Requires a directory (like /foo/.hg)
+    """
+    fh, fn = tempfile.mkstemp("", "", path)
+    os.close(fh)
+    m = os.stat(fn).st_mode
+    os.chmod(fn, m ^ 0111)
+    r = (os.stat(fn).st_mode != m)
+    os.unlink(fn)
+    return r
+
 # Platform specific variants
 if os.name == 'nt':
     import msvcrt