Mercurial > public > mercurial-scm > hg
comparison mercurial/posix.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 | 2aa3e07b2f07 |
children | 8413916df816 |
comparison
equal
deleted
inserted
replaced
15010:c3114acd8ea2 | 15011:5e44e4b3a0a3 |
---|---|
82 os.chmod(f, s | (s & 0444) >> 2 & ~umask) | 82 os.chmod(f, s | (s & 0444) >> 2 & ~umask) |
83 elif not x and sx: | 83 elif not x and sx: |
84 # Turn off all +x bits | 84 # Turn off all +x bits |
85 os.chmod(f, s & 0666) | 85 os.chmod(f, s & 0666) |
86 | 86 |
87 def copymode(src, dst, mode=None): | |
88 '''Copy the file mode from the file at path src to dst. | |
89 If src doesn't exist, we're using mode instead. If mode is None, we're | |
90 using umask.''' | |
91 try: | |
92 st_mode = os.lstat(src).st_mode & 0777 | |
93 except OSError, inst: | |
94 if inst.errno != errno.ENOENT: | |
95 raise | |
96 st_mode = mode | |
97 if st_mode is None: | |
98 st_mode = ~umask | |
99 st_mode &= 0666 | |
100 os.chmod(dst, st_mode) | |
101 | |
87 def checkexec(path): | 102 def checkexec(path): |
88 """ | 103 """ |
89 Check whether the given path is on a filesystem with UNIX-like exec flags | 104 Check whether the given path is on a filesystem with UNIX-like exec flags |
90 | 105 |
91 Requires a directory (like /foo/.hg) | 106 Requires a directory (like /foo/.hg) |