/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/transport/__init__.py

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
688
688
            # Now that we've read some data, see if we can yield anything back
689
689
            while cur_offset_and_size in data_map:
690
690
                this_data = data_map.pop(cur_offset_and_size)
691
 
                yield cur_offset_and_size[0], this_data
692
 
                cur_offset_and_size = offset_stack.next()
 
691
                this_offset = cur_offset_and_size[0]
 
692
                try:
 
693
                    cur_offset_and_size = offset_stack.next()
 
694
                except StopIteration:
 
695
                    # Close the file handle as there will be no more data
 
696
                    # The handle would normally be cleaned up as this code goes
 
697
                    # out of scope, but as we are a generator, not all code
 
698
                    # will re-enter once we have consumed all the expected
 
699
                    # data. For example:
 
700
                    #   zip(range(len(requests)), readv(foo, requests))
 
701
                    # Will stop because the range is done, and not run the
 
702
                    # cleanup code for the readv().
 
703
                    fp.close()
 
704
                    cur_offset_and_size = None
 
705
                yield this_offset, this_data
693
706
 
694
707
    def _sort_expand_and_combine(self, offsets, upper_limit):
695
708
        """Helper for readv.
1022
1035
        implement it.
1023
1036
        """
1024
1037
        source = self.clone(from_relpath)
1025
 
        self.mkdir(to_relpath)
1026
1038
        target = self.clone(to_relpath)
 
1039
        target.mkdir('.')
 
1040
        source.copy_tree_to_transport(target)
 
1041
 
 
1042
    def copy_tree_to_transport(self, to_transport):
 
1043
        """Copy a subtree from one transport to another.
 
1044
 
 
1045
        self.base is used as the source tree root, and to_transport.base
 
1046
        is used as the target.  to_transport.base must exist (and be a
 
1047
        directory).
 
1048
        """
1027
1049
        files = []
1028
1050
        directories = ['.']
1029
1051
        while directories:
1030
1052
            dir = directories.pop()
1031
1053
            if dir != '.':
1032
 
                target.mkdir(dir)
1033
 
            for path in source.list_dir(dir):
 
1054
                to_transport.mkdir(dir)
 
1055
            for path in self.list_dir(dir):
1034
1056
                path = dir + '/' + path
1035
 
                stat = source.stat(path)
 
1057
                stat = self.stat(path)
1036
1058
                if S_ISDIR(stat.st_mode):
1037
1059
                    directories.append(path)
1038
1060
                else:
1039
1061
                    files.append(path)
1040
 
        source.copy_to(files, target)
 
1062
        self.copy_to(files, to_transport)
1041
1063
 
1042
1064
    def rename(self, rel_from, rel_to):
1043
1065
        """Rename a file or directory.