diff mercurial/util.py @ 3996:c190df14338c

exec: add execfunc to simplify exec flag support on non-exec filesystems
author Matt Mackall <mpm@selenic.com>
date Fri, 29 Dec 2006 20:04:30 -0600
parents a4e79f86d304
children 3f0ba82c103f
line wrap: on
line diff
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -707,6 +707,12 @@ def checkexec(path):
     os.unlink(fn)
     return r
 
+def execfunc(path, fallback):
+    '''return an is_exec() function with default to fallback'''
+    if checkexec(path):
+        return lambda x: is_exec(os.path.join(path, x), False)
+    return fallback
+
 # Platform specific variants
 if os.name == 'nt':
     import msvcrt