~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/local.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-09-06 22:55:29 UTC
  • mfrom: (1946.2.16 reduce-knit-churn)
  • Revision ID: pqm@pqm.ubuntu.com-20060906225529-7b367edabbb1ffc2
(jam) delay creating knit contents for significantly better new commit and push performance

Show diffs side-by-side

added added

removed removed

Lines of Context:
177
177
 
178
178
    def _put_non_atomic_helper(self, relpath, writer,
179
179
                               mode=None,
180
 
                               create_parent_dir=False):
 
180
                               create_parent_dir=False,
 
181
                               dir_mode=None):
181
182
        """Common functionality information for the put_*_non_atomic.
182
183
 
183
184
        This tracks all the create_parent_dir stuff.
206
207
            parent_dir = os.path.dirname(abspath)
207
208
            if not parent_dir:
208
209
                self._translate_error(e, relpath)
209
 
            try:
210
 
                os.mkdir(parent_dir)
211
 
            except (IOError, OSError), e:
212
 
                self._translate_error(e, relpath)
 
210
            self._mkdir(parent_dir, mode=dir_mode)
213
211
            # We created the parent directory, lets try to open the
214
212
            # file again
215
213
            try:
227
225
            os.close(fd)
228
226
 
229
227
    def put_file_non_atomic(self, relpath, f, mode=None,
230
 
                            create_parent_dir=False):
 
228
                            create_parent_dir=False,
 
229
                            dir_mode=None):
231
230
        """Copy the file-like object into the target location.
232
231
 
233
232
        This function is not strictly safe to use. It is only meant to
246
245
        def writer(fd):
247
246
            self._pump_to_fd(f, fd)
248
247
        self._put_non_atomic_helper(relpath, writer, mode=mode,
249
 
                                    create_parent_dir=create_parent_dir)
 
248
                                    create_parent_dir=create_parent_dir,
 
249
                                    dir_mode=dir_mode)
250
250
 
251
251
    def put_bytes_non_atomic(self, relpath, bytes, mode=None,
252
 
                             create_parent_dir=False):
 
252
                             create_parent_dir=False, dir_mode=None):
253
253
        def writer(fd):
254
254
            os.write(fd, bytes)
255
255
        self._put_non_atomic_helper(relpath, writer, mode=mode,
256
 
                                    create_parent_dir=create_parent_dir)
 
256
                                    create_parent_dir=create_parent_dir,
 
257
                                    dir_mode=dir_mode)
257
258
 
258
259
    def iter_files_recursive(self):
259
260
        """Iter the relative paths of files in the transports sub-tree."""
267
268
            else:
268
269
                yield relpath
269
270
 
270
 
    def mkdir(self, relpath, mode=None):
271
 
        """Create a directory at the given path."""
272
 
        path = relpath
 
271
    def _mkdir(self, abspath, mode=None):
 
272
        """Create a real directory, filtering through mode"""
 
273
        if mode is None:
 
274
            # os.mkdir() will filter through umask
 
275
            local_mode = 0777
 
276
        else:
 
277
            local_mode = mode
273
278
        try:
274
 
            if mode is None:
275
 
                # os.mkdir() will filter through umask
276
 
                local_mode = 0777
277
 
            else:
278
 
                local_mode = mode
279
 
            path = self._abspath(relpath)
280
 
            os.mkdir(path, local_mode)
 
279
            os.mkdir(abspath, local_mode)
281
280
            if mode is not None:
282
281
                # It is probably faster to just do the chmod, rather than
283
282
                # doing a stat, and then trying to compare
284
 
                os.chmod(path, mode)
 
283
                os.chmod(abspath, mode)
285
284
        except (IOError, OSError),e:
286
 
            self._translate_error(e, path)
 
285
            self._translate_error(e, abspath)
 
286
 
 
287
    def mkdir(self, relpath, mode=None):
 
288
        """Create a directory at the given path."""
 
289
        self._mkdir(self._abspath(relpath), mode=mode)
287
290
 
288
291
    def _get_append_file(self, relpath, mode=None):
289
292
        """Call os.open() for the given relpath"""