/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

  • Committer: John Arbash Meinel
  • Date: 2008-09-05 21:23:34 UTC
  • mto: This revision was merged to the branch mainline in revision 3701.
  • Revision ID: john@arbash-meinel.com-20080905212334-69j0qvvr9trvfk1b
Respond to Martin's review comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
751
751
        return offsets
752
752
 
753
753
    @staticmethod
754
 
    def _coalesce_offsets(offsets, limit=0, fudge_factor=0, max_size=0,
755
 
                          allow_overlap=False):
 
754
    def _coalesce_offsets(offsets, limit=0, fudge_factor=0, max_size=0):
756
755
        """Yield coalesced offsets.
757
756
 
758
757
        With a long list of neighboring requests, combine them
759
758
        into a single large request, while retaining the original
760
759
        offsets.
761
760
        Turns  [(15, 10), (25, 10)] => [(15, 20, [(0, 10), (10, 10)])]
 
761
        Note that overlapping requests are not permitted. (So [(15, 10), (20,
 
762
        10)] will raise a ValueError.) This is because the data we access never
 
763
        overlaps, and it allows callers to trust that we only need any byte of
 
764
        data for 1 request (so nothing needs to be buffered to fulfill a second
 
765
        request.)
762
766
 
763
767
        :param offsets: A list of (start, length) pairs
764
768
        :param limit: Only combine a maximum of this many pairs Some transports
772
776
                When a single offset is bigger than 'max_size', it will keep
773
777
                its size and be alone in the coalesced offset.
774
778
                0 means no maximum size.
775
 
        :param allow_overlap: If False, raise an error if requested ranges
776
 
            overlap.
777
779
        :return: return a list of _CoalescedOffset objects, which have members
778
780
            for where to start, how much to read, and how to split those chunks
779
781
            back up
789
791
                and start >= cur.start
790
792
                and (limit <= 0 or len(cur.ranges) < limit)
791
793
                and (max_size <= 0 or end - cur.start <= max_size)):
792
 
                if not allow_overlap and start < last_end:
793
 
                    raise errors.OverlappingReadv()
 
794
                if start < last_end:
 
795
                    raise errors.ValueError('Overlapping range not allowed:'
 
796
                        ' last range ended at %s, new one starts at %s'
 
797
                        % (last_end, start))
794
798
                cur.length = end - cur.start
795
799
                cur.ranges.append((start-cur.start, size))
796
800
            else: