changeset 3994:1cc60eebc71f

exec: checkexec checks whether filesystem supports exec flags
author Matt Mackall <mpm@selenic.com>
date Fri, 29 Dec 2006 20:04:30 -0600
parents 04d919cdf263
children a4e79f86d304
files mercurial/util.py
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -693,6 +693,20 @@ def checkfolding(path):
     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