~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/local.py

  • Committer: Launchpad Translations on behalf of bzr-core
  • Date: 2012-07-21 04:30:31 UTC
  • mto: (6581.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 6582.
  • Revision ID: launchpad_translations_on_behalf_of_bzr-core-20120721043031-pjhomz88j0qw381z
Launchpad automatic translations update.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
This is a fairly thin wrapper on regular file IO.
20
20
"""
21
21
 
 
22
from __future__ import absolute_import
 
23
 
22
24
import os
23
25
from stat import ST_MODE, S_ISDIR, S_IMODE
24
26
import sys
146
148
        if abspath is None:
147
149
            abspath = u'.'
148
150
 
149
 
        return urlutils.file_relpath(
150
 
            urlutils.strip_trailing_slash(self.base),
151
 
            urlutils.strip_trailing_slash(abspath))
 
151
        return urlutils.file_relpath(self.base, abspath)
152
152
 
153
153
    def has(self, relpath):
154
154
        return os.access(self._abspath(relpath), os.F_OK)
257
257
            if mode is not None and mode != S_IMODE(st.st_mode):
258
258
                # Because of umask, we may still need to chmod the file.
259
259
                # But in the general case, we won't have to
260
 
                os.chmod(abspath, mode)
 
260
                osutils.chmod_if_possible(abspath, mode)
261
261
            writer(fd)
262
262
        finally:
263
263
            os.close(fd)
316
316
            local_mode = mode
317
317
        try:
318
318
            os.mkdir(abspath, local_mode)
319
 
            if mode is not None:
320
 
                # It is probably faster to just do the chmod, rather than
321
 
                # doing a stat, and then trying to compare
322
 
                os.chmod(abspath, mode)
323
319
        except (IOError, OSError),e:
324
320
            self._translate_error(e, abspath)
 
321
        if mode is not None:
 
322
            try:
 
323
                osutils.chmod_if_possible(abspath, mode)
 
324
            except (IOError, OSError), e:
 
325
                self._translate_error(e, abspath)
325
326
 
326
327
    def mkdir(self, relpath, mode=None):
327
328
        """Create a directory at the given path."""
359
360
        if mode is not None and mode != S_IMODE(st.st_mode):
360
361
            # Because of umask, we may still need to chmod the file.
361
362
            # But in the general case, we won't have to
362
 
            os.chmod(file_abspath, mode)
 
363
            osutils.chmod_if_possible(file_abspath, mode)
363
364
        return st.st_size
364
365
 
365
366
    def append_file(self, relpath, f, mode=None):
458
459
                    otherpath = other._abspath(path)
459
460
                    shutil.copy(mypath, otherpath)
460
461
                    if mode is not None:
461
 
                        os.chmod(otherpath, mode)
 
462
                        osutils.chmod_if_possible(otherpath, mode)
462
463
                except (IOError, OSError),e:
463
464
                    self._translate_error(e, path)
464
465
                count += 1
540
541
            """See Transport.symlink."""
541
542
            abs_link_dirpath = urlutils.dirname(self.abspath(link_name))
542
543
            source_rel = urlutils.file_relpath(
543
 
                urlutils.strip_trailing_slash(abs_link_dirpath),
544
 
                urlutils.strip_trailing_slash(self.abspath(source))
545
 
            )
 
544
                abs_link_dirpath, self.abspath(source))
546
545
 
547
546
            try:
548
547
                os.symlink(source_rel, self._abspath(link_name))
567
566
        self._local_base = urlutils._win32_local_path_from_url(base)
568
567
 
569
568
    def abspath(self, relpath):
570
 
        path = osutils.normpath(osutils.pathjoin(
 
569
        path = osutils._win32_normpath(osutils.pathjoin(
571
570
                    self._local_base, urlutils.unescape(relpath)))
572
571
        return urlutils._win32_local_path_to_url(path)
573
572