~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/sftp.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-02-22 07:59:56 UTC
  • mfrom: (1553.5.33 bzr.mbp.locks)
  • Revision ID: pqm@pqm.ubuntu.com-20060222075956-fb281c427e571da6
add LockDir and related fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
417
417
                self._sftp.chmod(tmp_abspath, mode)
418
418
            fout.close()
419
419
            closed = True
420
 
            self._rename(tmp_abspath, abspath)
 
420
            self._rename_and_overwrite(tmp_abspath, abspath)
421
421
        except Exception, e:
422
422
            # If we fail, try to clean up the temporary file
423
423
            # before we throw the exception
505
505
        except (IOError, paramiko.SSHException), e:
506
506
            self._translate_io_exception(e, relpath, ': unable to append')
507
507
 
508
 
    def _rename(self, abs_from, abs_to):
 
508
    def rename(self, rel_from, rel_to):
 
509
        """Rename without special overwriting"""
 
510
        try:
 
511
            self._sftp.rename(self._remote_path(rel_from),
 
512
                              self._remote_path(rel_to))
 
513
        except (IOError, paramiko.SSHException), e:
 
514
            self._translate_io_exception(e, rel_from,
 
515
                    ': unable to rename to %r' % (rel_to))
 
516
 
 
517
    def _rename_and_overwrite(self, abs_from, abs_to):
509
518
        """Do a fancy rename on the remote server.
510
519
        
511
520
        Using the implementation provided by osutils.
521
530
        """Move the item at rel_from to the location at rel_to"""
522
531
        path_from = self._remote_path(rel_from)
523
532
        path_to = self._remote_path(rel_to)
524
 
        self._rename(path_from, path_to)
 
533
        self._rename_and_overwrite(path_from, path_to)
525
534
 
526
535
    def delete(self, relpath):
527
536
        """Delete the item at relpath"""