/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 breezy/_groupcompress_py.py

  • Committer: Martin
  • Date: 2017-06-04 18:09:30 UTC
  • mto: This revision was merged to the branch mainline in revision 6653.
  • Revision ID: gzlist@googlemail.com-20170604180930-zpcenvzu13lilaax
Apply 2to3 xrange fix and fix up with sixish range

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
from __future__ import absolute_import
24
24
 
25
25
from . import osutils
 
26
from .sixish import (
 
27
    range,
 
28
    )
26
29
 
27
30
 
28
31
class _OutputHandler(object):
38
41
    def add_copy(self, start_byte, end_byte):
39
42
        # The data stream allows >64kB in a copy, but to match the compiled
40
43
        # code, we will also limit it to a 64kB copy
41
 
        for start_byte in xrange(start_byte, end_byte, 64*1024):
 
44
        for start_byte in range(start_byte, end_byte, 64*1024):
42
45
            num_bytes = min(64*1024, end_byte - start_byte)
43
46
            copy_bytes = encode_copy_instruction(start_byte, num_bytes)
44
47
            self.out_lines.append(copy_bytes)
64
67
        # Flush out anything pending
65
68
        self._flush_insert()
66
69
        line_len = len(line)
67
 
        for start_index in xrange(0, line_len, 127):
 
70
        for start_index in range(0, line_len, 127):
68
71
            next_len = min(127, line_len - start_index)
69
72
            self.out_lines.append(chr(next_len))
70
73
            self.index_lines.append(False)
256
259
        bytes_to_insert = ''.join(new_lines[start_linenum:end_linenum])
257
260
        insert_length = len(bytes_to_insert)
258
261
        # Each insert instruction is at most 127 bytes long
259
 
        for start_byte in xrange(0, insert_length, 127):
 
262
        for start_byte in range(0, insert_length, 127):
260
263
            insert_count = min(insert_length - start_byte, 127)
261
264
            out_lines.append(chr(insert_count))
262
265
            # Don't index the 'insert' instruction
276
279
        num_bytes = stop_byte - first_byte
277
280
        # The data stream allows >64kB in a copy, but to match the compiled
278
281
        # code, we will also limit it to a 64kB copy
279
 
        for start_byte in xrange(first_byte, stop_byte, 64*1024):
 
282
        for start_byte in range(first_byte, stop_byte, 64*1024):
280
283
            num_bytes = min(64*1024, stop_byte - start_byte)
281
284
            copy_bytes = encode_copy_instruction(start_byte, num_bytes)
282
285
            out_lines.append(copy_bytes)