[PATCH] vfs: fix fchmod() call for Windows (partial fix for 76b73ce0ffac)

Adrian Buehlmann adrian at cadifra.com
Sat Oct 13 05:53:03 CDT 2012


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1350125422 -7200
# Node ID a879621bfe0952b540ba5aae9f61c807614a8ff5
# Parent  fec69c72e2b4b159512fb0d37707d635554ae1cf
vfs: fix fchmod() call for Windows (partial fix for 76b73ce0ffac)

Still unsolved: os.fchmod is not available on Python <= 2.5

diff --git a/mercurial/posix.py b/mercurial/posix.py
--- a/mercurial/posix.py
+++ b/mercurial/posix.py
@@ -94,6 +94,9 @@
         # Turn off all +x bits
         os.chmod(f, s & 0666)
 
+def fchmod(fd, mode):
+    os.fchmod(fd, mode & 0666)
+
 def copymode(src, dst, mode=None):
     '''Copy the file mode from the file at path src to dst.
     If src doesn't exist, we're using mode instead. If mode is None, we're
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -258,7 +258,7 @@
     def _fixfilemode(self, fp):
         if self.createmode is None:
             return
-        os.fchmod(fp.fileno(), self.createmode & 0666)
+        util.fchmod(fp.fileno(), self.createmode)
 
     def __call__(self, path, mode="r", text=False, atomictemp=False):
         if self._audit:
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -31,6 +31,7 @@
 executablepath = platform.executablepath
 expandglobs = platform.expandglobs
 explainexit = platform.explainexit
+fchmod = platform.fchmod
 findexe = platform.findexe
 gethgcmd = platform.gethgcmd
 getuser = platform.getuser
diff --git a/mercurial/windows.py b/mercurial/windows.py
--- a/mercurial/windows.py
+++ b/mercurial/windows.py
@@ -105,6 +105,9 @@
 def setflags(f, l, x):
     pass
 
+def fchmod(fd, mode):
+    pass
+
 def copymode(src, dst, mode=None):
     pass
 


More information about the Mercurial-devel mailing list