Mercurial > hg
comparison mercurial/manifest.py @ 32535:260a6f715bd2
manifest: fix some pure-Python parser bits to work on Python 3
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Sun, 28 May 2017 21:29:15 -0400 |
parents | df448de7cf3b |
children | aa333c1982ab |
comparison
equal
deleted
inserted
replaced
32534:0048a852b6aa | 32535:260a6f715bd2 |
---|---|
31 # This method does a little bit of excessive-looking | 31 # This method does a little bit of excessive-looking |
32 # precondition checking. This is so that the behavior of this | 32 # precondition checking. This is so that the behavior of this |
33 # class exactly matches its C counterpart to try and help | 33 # class exactly matches its C counterpart to try and help |
34 # prevent surprise breakage for anyone that develops against | 34 # prevent surprise breakage for anyone that develops against |
35 # the pure version. | 35 # the pure version. |
36 if data and data[-1] != '\n': | 36 if data and data[-1:] != '\n': |
37 raise ValueError('Manifest did not end in a newline.') | 37 raise ValueError('Manifest did not end in a newline.') |
38 prev = None | 38 prev = None |
39 for l in data.splitlines(): | 39 for l in data.splitlines(): |
40 if prev is not None and prev > l: | 40 if prev is not None and prev > l: |
41 raise ValueError('Manifest lines not in sorted order.') | 41 raise ValueError('Manifest lines not in sorted order.') |
53 prevf = '' | 53 prevf = '' |
54 while pos < len(data): | 54 while pos < len(data): |
55 end = data.find('\n', pos + 1) # +1 to skip stem length byte | 55 end = data.find('\n', pos + 1) # +1 to skip stem length byte |
56 if end == -1: | 56 if end == -1: |
57 raise ValueError('Manifest ended with incomplete file entry.') | 57 raise ValueError('Manifest ended with incomplete file entry.') |
58 stemlen = ord(data[pos]) | 58 stemlen = ord(data[pos:pos + 1]) |
59 items = data[pos + 1:end].split('\0') | 59 items = data[pos + 1:end].split('\0') |
60 f = prevf[:stemlen] + items[0] | 60 f = prevf[:stemlen] + items[0] |
61 if prevf > f: | 61 if prevf > f: |
62 raise ValueError('Manifest entries not in sorted order.') | 62 raise ValueError('Manifest entries not in sorted order.') |
63 fl = items[1] | 63 fl = items[1] |