~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/local.py

  • Committer: Neil Santos
  • Date: 2010-02-25 03:23:48 UTC
  • mto: (5080.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5081.
  • Revision ID: neil_santos@users.sourceforge.net-20100225032348-pi4bes9ehqjg394c
Added default link() and symlink() methods to Transport.
Added implementation of link() and symlink() methods to LocalTransport.
Added implementation of symlink() method to SFTPTransport.
Added corresponding tests (symlink() fails for SFTPTransport for some reason; possibly a Paramiko bug?).
Committing in preparation for push and eventual merge proposal to mainline bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
481
481
        path = relpath
482
482
        try:
483
483
            path = self._abspath(relpath)
484
 
            return os.stat(path)
 
484
            return os.lstat(path)
485
485
        except (IOError, OSError),e:
486
486
            self._translate_error(e, path)
487
487
 
515
515
        except (IOError, OSError),e:
516
516
            self._translate_error(e, path)
517
517
 
 
518
    def link(self, source, link_name):
 
519
        """See Transport.link."""
 
520
        try:
 
521
            os.link(self._abspath(source),
 
522
                    self._abspath(link_name))
 
523
            return True
 
524
        except AttributeError:
 
525
            raise errors.TransportNotPossible("Hardlinks are not supported on %s" % self)
 
526
        except (IOError, OSError), e:
 
527
            self._translate_error(e, source)
 
528
 
 
529
    def symlink(self, source, link_name):
 
530
        """See Transport.symlink."""
 
531
        abs_link_dirpath = urlutils.dirname(self.abspath(link_name))
 
532
        source_rel = urlutils.file_relpath(
 
533
            urlutils.strip_trailing_slash(abs_link_dirpath),
 
534
            urlutils.strip_trailing_slash(self.abspath(source))
 
535
        )
 
536
 
 
537
        try:
 
538
            os.symlink(source_rel, self._abspath(link_name))
 
539
            return True
 
540
        except AttributeError:
 
541
            raise errors.TransportNotPossible("Symlinks are not supported on %s" % self)
 
542
        except (IOError, OSError), e:
 
543
            self._translate_error(e, source_rel)
 
544
 
518
545
    def _can_roundtrip_unix_modebits(self):
519
546
        if sys.platform == 'win32':
520
547
            # anyone else?