97
97
mod = os.lstat(filename).st_mode
98
98
if not stat.S_ISLNK(mod):
99
99
mod = mod & 0777555
100
os.chmod(filename, mod)
100
chmod_if_possible(filename, mod)
103
103
def make_writable(filename):
104
104
mod = os.lstat(filename).st_mode
105
105
if not stat.S_ISLNK(mod):
107
os.chmod(filename, mod)
107
chmod_if_possible(filename, mod)
110
def chmod_if_possible(filename, mode):
111
# Set file mode if that can be safely done.
112
# Sometimes even on unix the filesystem won't allow it - see
113
# https://bugs.launchpad.net/bzr/+bug/606537
115
# It is probably faster to just do the chmod, rather than
116
# doing a stat, and then trying to compare
117
os.chmod(filename, mode)
118
except (IOError, OSError),e:
119
# Permission/access denied seems to commonly happen on smbfs; there's
120
# probably no point warning about it.
121
# <https://bugs.launchpad.net/bzr/+bug/606537>
122
if getattr(e, 'errno') in (errno.EPERM, errno.EACCES):
123
trace.mutter("ignore error on chmod of %r: %r" % (
110
129
def minimum_path_selection(paths):