~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/local.py

merge permissions branch, also fixup tests so they are lined up with bzr.dev to help prevent conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
82
82
        except (IOError, OSError),e:
83
83
            self._translate_error(e, path)
84
84
 
85
 
    def put(self, relpath, f):
 
85
    def put(self, relpath, f, mode=None):
86
86
        """Copy the file-like or string object into the location.
87
87
 
88
88
        :param relpath: Location to put the contents, relative to base.
93
93
        path = relpath
94
94
        try:
95
95
            path = self.abspath(relpath)
96
 
            fp = AtomicFile(path, 'wb')
 
96
            fp = AtomicFile(path, 'wb', new_mode=mode)
97
97
        except (IOError, OSError),e:
98
98
            self._translate_error(e, path)
99
99
        try:
114
114
            else:
115
115
                yield relpath
116
116
 
117
 
    def mkdir(self, relpath):
 
117
    def mkdir(self, relpath, mode=None):
118
118
        """Create a directory at the given path."""
119
119
        path = relpath
120
120
        try:
121
121
            path = self.abspath(relpath)
122
122
            os.mkdir(path)
 
123
            if mode is not None:
 
124
                os.chmod(path, mode)
123
125
        except (IOError, OSError),e:
124
126
            self._translate_error(e, path)
125
127
 
162
164
            # TODO: What about path_to?
163
165
            self._translate_error(e, path)
164
166
 
165
 
    def copy_to(self, relpaths, other, pb=None):
 
167
    def copy_to(self, relpaths, other, mode=None, pb=None):
166
168
        """Copy a set of entries from self into another Transport.
167
169
 
168
170
        :param relpaths: A list/generator of entries to be copied.
178
180
            for path in relpaths:
179
181
                self._update_pb(pb, 'copy-to', count, total)
180
182
                try:
181
 
                    shutil.copy(self.abspath(path), other.abspath(path))
 
183
                    mypath = self.abspath(path)
 
184
                    otherpath = other.abspath(path)
 
185
                    shutil.copy(mypath, otherpath)
 
186
                    if mode is not None:
 
187
                        os.chmod(otherpath, mode)
182
188
                except (IOError, OSError),e:
183
189
                    self._translate_error(e, path)
184
190
                count += 1
185
191
            return count
186
192
        else:
187
 
            return super(LocalTransport, self).copy_to(relpaths, other, pb=pb)
 
193
            return super(LocalTransport, self).copy_to(relpaths, other, mode=mode, pb=pb)
188
194
 
189
195
    def listable(self):
190
196
        """See Transport.listable."""