~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/sftp.py

  • Committer: Martin Pool
  • Date: 2006-02-21 06:02:01 UTC
  • mto: This revision was merged to the branch mainline in revision 1569.
  • Revision ID: mbp@sourcefrog.net-20060221060201-5f260bfe331bdc42
New Transport.rename that mustn't overwrite
Change LockDir.is_held to be a property

Show diffs side-by-side

added added

removed removed

Lines of Context:
405
405
                self._sftp.chmod(tmp_abspath, mode)
406
406
            fout.close()
407
407
            closed = True
408
 
            self._rename(tmp_abspath, abspath)
 
408
            self._rename_and_overwrite(tmp_abspath, abspath)
409
409
        except Exception, e:
410
410
            # If we fail, try to clean up the temporary file
411
411
            # before we throw the exception
493
493
        except (IOError, paramiko.SSHException), e:
494
494
            self._translate_io_exception(e, relpath, ': unable to append')
495
495
 
496
 
    def _rename(self, abs_from, abs_to):
 
496
    def rename(self, rel_from, rel_to):
 
497
        """Rename without special overwriting"""
 
498
        try:
 
499
            self._sftp.rename(self._remote_path(rel_from),
 
500
                              self._remote_path(rel_to))
 
501
        except (IOError, paramiko.SSHException), e:
 
502
            self._translate_io_exception(e, rel_from,
 
503
                    ': unable to rename to %r' % (rel_to))
 
504
 
 
505
    def _rename_and_overwrite(self, abs_from, abs_to):
497
506
        """Do a fancy rename on the remote server.
498
507
        
499
508
        Using the implementation provided by osutils.
509
518
        """Move the item at rel_from to the location at rel_to"""
510
519
        path_from = self._remote_path(rel_from)
511
520
        path_to = self._remote_path(rel_to)
512
 
        self._rename(path_from, path_to)
 
521
        self._rename_and_overwrite(path_from, path_to)
513
522
 
514
523
    def delete(self, relpath):
515
524
        """Delete the item at relpath"""