~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

(mbp) squelch chmod errors,
 to cope with non-unixy unix filesystems (Martin Pool)

Show diffs side-by-side

added added

removed removed

Lines of Context:
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)
101
101
 
102
102
 
103
103
def make_writable(filename):
104
104
    mod = os.lstat(filename).st_mode
105
105
    if not stat.S_ISLNK(mod):
106
106
        mod = mod | 0200
107
 
        os.chmod(filename, mod)
 
107
        chmod_if_possible(filename, mod)
 
108
 
 
109
 
 
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
 
114
    try:
 
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" % (
 
124
                filename, e))
 
125
            return
 
126
        raise
108
127
 
109
128
 
110
129
def minimum_path_selection(paths):