diff mercurial/util.py @ 15011:5e44e4b3a0a3

util: move copymode into posix.py and windows.py reducing it to a NOP on Windows. This eliminates a pointless stat call on Windows and reduces the risk of interferring with other processes (e.g. AV-scanners, file change watchers). See also http://mercurial.selenic.com/wiki/UnlinkingFilesOnWindows, item 2d
author Adrian Buehlmann <adrian@cadifra.com>
date Tue, 02 Aug 2011 13:18:56 +0200
parents c3114acd8ea2
children 1e45b92f4fb2
line wrap: on
line diff
--- a/mercurial/util.py	Tue Aug 02 12:29:48 2011 +0200
+++ b/mercurial/util.py	Tue Aug 02 13:18:56 2011 +0200
@@ -27,6 +27,7 @@
 cachestat = platform.cachestat
 checkexec = platform.checkexec
 checklink = platform.checklink
+copymode = platform.copymode
 executablepath = platform.executablepath
 expandglobs = platform.expandglobs
 explainexit = platform.explainexit
@@ -701,21 +702,6 @@
     else:
         return os.name == "nt" or os.environ.get("DISPLAY")
 
-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
-    using umask.'''
-    try:
-        st_mode = os.lstat(src).st_mode & 0777
-    except OSError, inst:
-        if inst.errno != errno.ENOENT:
-            raise
-        st_mode = mode
-        if st_mode is None:
-            st_mode = ~umask
-        st_mode &= 0666
-    os.chmod(dst, st_mode)
-
 def mktempcopy(name, emptyok=False, createmode=None):
     """Create a temporary file with the same contents from name