Show More
@@ -11,6 +11,26 b' import array, struct' | |||||
11 |
|
11 | |||
12 | propertycache = util.propertycache |
|
12 | propertycache = util.propertycache | |
13 |
|
13 | |||
|
14 | def _parse(data): | |||
|
15 | """Generates (path, node, flags) tuples from a manifest text""" | |||
|
16 | # This method does a little bit of excessive-looking | |||
|
17 | # precondition checking. This is so that the behavior of this | |||
|
18 | # class exactly matches its C counterpart to try and help | |||
|
19 | # prevent surprise breakage for anyone that develops against | |||
|
20 | # the pure version. | |||
|
21 | if data and data[-1] != '\n': | |||
|
22 | raise ValueError('Manifest did not end in a newline.') | |||
|
23 | prev = None | |||
|
24 | for l in data.splitlines(): | |||
|
25 | if prev is not None and prev > l: | |||
|
26 | raise ValueError('Manifest lines not in sorted order.') | |||
|
27 | prev = l | |||
|
28 | f, n = l.split('\0') | |||
|
29 | if len(n) > 40: | |||
|
30 | yield f, revlog.bin(n[:40]), n[40:] | |||
|
31 | else: | |||
|
32 | yield f, revlog.bin(n), '' | |||
|
33 | ||||
14 | class _lazymanifest(dict): |
|
34 | class _lazymanifest(dict): | |
15 | """This is the pure implementation of lazymanifest. |
|
35 | """This is the pure implementation of lazymanifest. | |
16 |
|
36 | |||
@@ -18,24 +38,9 b' class _lazymanifest(dict):' | |||||
18 | """ |
|
38 | """ | |
19 |
|
39 | |||
20 | def __init__(self, data): |
|
40 | def __init__(self, data): | |
21 | # This init method does a little bit of excessive-looking |
|
|||
22 | # precondition checking. This is so that the behavior of this |
|
|||
23 | # class exactly matches its C counterpart to try and help |
|
|||
24 | # prevent surprise breakage for anyone that develops against |
|
|||
25 | # the pure version. |
|
|||
26 | if data and data[-1] != '\n': |
|
|||
27 | raise ValueError('Manifest did not end in a newline.') |
|
|||
28 | dict.__init__(self) |
|
41 | dict.__init__(self) | |
29 | prev = None |
|
42 | for f, n, fl in _parse(data): | |
30 | for l in data.splitlines(): |
|
43 | self[f] = n, fl | |
31 | if prev is not None and prev > l: |
|
|||
32 | raise ValueError('Manifest lines not in sorted order.') |
|
|||
33 | prev = l |
|
|||
34 | f, n = l.split('\0') |
|
|||
35 | if len(n) > 40: |
|
|||
36 | self[f] = revlog.bin(n[:40]), n[40:] |
|
|||
37 | else: |
|
|||
38 | self[f] = revlog.bin(n), '' |
|
|||
39 |
|
44 | |||
40 | def __setitem__(self, k, v): |
|
45 | def __setitem__(self, k, v): | |
41 | node, flag = v |
|
46 | node, flag = v | |
@@ -342,8 +347,7 b' class treemanifest(object):' | |||||
342 | # Using _lazymanifest here is a little slower than plain old dicts |
|
347 | # Using _lazymanifest here is a little slower than plain old dicts | |
343 | self._files = {} |
|
348 | self._files = {} | |
344 | self._flags = {} |
|
349 | self._flags = {} | |
345 | lm = _lazymanifest(text) |
|
350 | for f, n, fl in _parse(text): | |
346 | for f, n, fl in lm.iterentries(): |
|
|||
347 | self[f] = n |
|
351 | self[f] = n | |
348 | if fl: |
|
352 | if fl: | |
349 | self.setflag(f, fl) |
|
353 | self.setflag(f, fl) |
General Comments 0
You need to be logged in to leave comments.
Login now