Show More
@@ -11,6 +11,26 b' import array, struct' | |||
|
11 | 11 | |
|
12 | 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 | 34 | class _lazymanifest(dict): |
|
15 | 35 | """This is the pure implementation of lazymanifest. |
|
16 | 36 | |
@@ -18,24 +38,9 b' class _lazymanifest(dict):' | |||
|
18 | 38 | """ |
|
19 | 39 | |
|
20 | 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 | 41 | dict.__init__(self) |
|
29 | prev = None | |
|
30 | for l in data.splitlines(): | |
|
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), '' | |
|
42 | for f, n, fl in _parse(data): | |
|
43 | self[f] = n, fl | |
|
39 | 44 | |
|
40 | 45 | def __setitem__(self, k, v): |
|
41 | 46 | node, flag = v |
@@ -342,8 +347,7 b' class treemanifest(object):' | |||
|
342 | 347 | # Using _lazymanifest here is a little slower than plain old dicts |
|
343 | 348 | self._files = {} |
|
344 | 349 | self._flags = {} |
|
345 | lm = _lazymanifest(text) | |
|
346 | for f, n, fl in lm.iterentries(): | |
|
350 | for f, n, fl in _parse(text): | |
|
347 | 351 | self[f] = n |
|
348 | 352 | if fl: |
|
349 | 353 | self.setflag(f, fl) |
General Comments 0
You need to be logged in to leave comments.
Login now