~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/__init__.py

  • Committer: John Arbash Meinel
  • Date: 2006-09-05 22:03:27 UTC
  • mto: (1946.2.8 reduce-knit-churn)
  • mto: This revision was merged to the branch mainline in revision 1988.
  • Revision ID: john@arbash-meinel.com-20060905220327-ed78d9feccf3c79c
Add non_atomic_put_bytes() and tests for it

Show diffs side-by-side

added added

removed removed

Lines of Context:
571
571
                self.mkdir(parent_dir)
572
572
                return self.put_file(relpath, f, mode=mode)
573
573
 
 
574
    def non_atomic_put_bytes(self, relpath, bytes, mode=None,
 
575
                             create_parent_dir=False):
 
576
        """Copy the string into the target location.
 
577
 
 
578
        This function is not strictly safe to use. See 
 
579
        Transport.non_atomic_put_bytes for more information.
 
580
 
 
581
        :param relpath: The remote location to put the contents.
 
582
        :param bytes:   A string object containing the raw bytes to write into
 
583
                        the target file.
 
584
        :param mode:    Possible access permissions for new file.
 
585
                        None means do not set remote permissions.
 
586
        :param create_parent_dir: If we cannot create the target file because
 
587
                        the parent directory does not exist, go ahead and
 
588
                        create it, and then try again.
 
589
        """
 
590
        assert isinstance(bytes, str), \
 
591
            'bytes must be a plain string, not %s' % type(bytes)
 
592
        self.non_atomic_put_file(relpath, StringIO(bytes), mode=mode,
 
593
                                 create_parent_dir=create_parent_dir)
 
594
 
574
595
    @deprecated_method(zero_eleven)
575
596
    def put_multi(self, files, mode=None, pb=None):
576
597
        """Put a set of files into the location.