~jelmer/brz/cachedir

« back to all changes in this revision

Viewing changes to breezy/_chunks_to_lines_py.py

  • Committer: Jelmer Vernooij
  • Date: 2018-04-02 23:59:32 UTC
  • mfrom: (6060.2.879 work)
  • Revision ID: jelmer@jelmer.uk-20180402235932-9gbg95uo4d0qu6bs
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""The python implementation of chunks_to_lines"""
18
18
 
 
19
from __future__ import absolute_import
 
20
 
19
21
 
20
22
def chunks_to_lines(chunks):
21
23
    """Re-split chunks into simple lines.
39
41
        if not chunk:
40
42
            # Empty strings are never valid lines
41
43
            break
42
 
        elif '\n' in chunk[:-1]:
 
44
        elif b'\n' in chunk[:-1]:
43
45
            # This chunk has an extra '\n', so we will have to split it
44
46
            break
45
 
        elif chunk[-1] != '\n':
 
47
        elif chunk[-1:] != b'\n':
46
48
            # This chunk does not have a trailing newline
47
49
            last_no_newline = True
48
50
    else:
53
55
        return chunks
54
56
 
55
57
    # These aren't simple lines, just join and split again.
56
 
    from bzrlib import osutils
57
 
    return osutils._split_lines(''.join(chunks))
 
58
    from breezy import osutils
 
59
    return osutils._split_lines(b''.join(chunks))