diff mercurial/util.py @ 441:e8af362cfb01

Permission handling for the other OS -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Permission handling for the other OS From: K Thananchayan <thananck@yahoo.com> Preserve exec permission under Windows on existing source files. Not an ideal solution as there is no way to specify exec permission for a new file. Nevertheless, this helps working on crossplatform projects. manifest hash: c50da52ad4645f40bd6204c4fd458e880bc3f801 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCuvJeywK+sNU5EO8RAscXAJ40eAHZjTip5to6BGPdoXxxL5gNQQCgl5GT 8S1Ckank5I/0ScGtapZKqTA= =QrQp -----END PGP SIGNATURE-----
author mpm@selenic.com
date Thu, 23 Jun 2005 09:33:18 -0800
parents 10c43444a38e
children 9ae0034f2772 50da4bb9cab6
line wrap: on
line diff
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -16,6 +16,12 @@ def rename(src, dst):
 
 # 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 @@ if os.name == 'nt':
     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