mercurial/util.py
changeset 441 e8af362cfb01
parent 422 10c43444a38e
child 461 9ae0034f2772
child 464 50da4bb9cab6
--- a/mercurial/util.py	Thu Jun 23 09:26:43 2005 -0800
+++ b/mercurial/util.py	Thu Jun 23 09:33:18 2005 -0800
@@ -16,6 +16,12 @@
 
 # Platfor specific varients
 if os.name == 'nt':
+    def is_exec(f, last):
+        return last
+
+    def set_exec(f, mode):
+        pass
+    
     def pconvert(path):
         return path.replace("\\", "/")
 
@@ -27,6 +33,22 @@
     def readlock(pathname):
         return file(pathname).read()
 else:
+    def is_exec(f, last):
+        return (os.stat(f).st_mode & 0100 != 0)
+
+    def set_exec(f, mode):
+        s = os.stat(f).st_mode
+        if (s & 0100 != 0) == mode:
+            return
+        if mode:
+            # Turn on +x for every +r bit when making a file executable
+            # and obey umask.
+            umask = os.umask(0)
+            os.umask(umask)
+            os.chmod(f, s | (s & 0444) >> 2 & ~umask)
+        else:
+            os.chmod(f, s & 0666)
+
     def pconvert(path):
         return path