Show More
@@ -126,6 +126,22 b' def _cmp(a, b):' | |||
|
126 | 126 | return (a > b) - (a < b) |
|
127 | 127 | |
|
128 | 128 | class _lazymanifest(object): |
|
129 | """A pure python manifest backed by a byte string. It is supplimented with | |
|
130 | internal lists as it is modified, until it is compacted back to a pure byte | |
|
131 | string. | |
|
132 | ||
|
133 | ``data`` is the initial manifest data. | |
|
134 | ||
|
135 | ``positions`` is a list of offsets, one per manifest entry. Positive | |
|
136 | values are offsets into ``data``, negative values are offsets into the | |
|
137 | ``extradata`` list. When an entry is removed, its entry is dropped from | |
|
138 | ``positions``. The values are encoded such that when walking the list and | |
|
139 | indexing into ``data`` or ``extradata`` as appropriate, the entries are | |
|
140 | sorted by filename. | |
|
141 | ||
|
142 | ``extradata`` is a list of (key, hash, flags) for entries that were added or | |
|
143 | modified since the manifest was created or compacted. | |
|
144 | """ | |
|
129 | 145 | def __init__(self, data, positions=None, extrainfo=None, extradata=None, |
|
130 | 146 | hasremovals=False): |
|
131 | 147 | if positions is None: |
@@ -246,6 +262,8 b' class _lazymanifest(object):' | |||
|
246 | 262 | self.positions = self.positions[:needle] + self.positions[needle + 1:] |
|
247 | 263 | self.extrainfo = self.extrainfo[:needle] + self.extrainfo[needle + 1:] |
|
248 | 264 | if cur >= 0: |
|
265 | # This does NOT unsort the list as far as the search functions are | |
|
266 | # concerned, as they only examine lines mapped by self.positions. | |
|
249 | 267 | self.data = self.data[:cur] + '\x00' + self.data[cur + 1:] |
|
250 | 268 | self.hasremovals = True |
|
251 | 269 | |
@@ -297,6 +315,10 b' class _lazymanifest(object):' | |||
|
297 | 315 | if self.positions[i] >= 0: |
|
298 | 316 | cur = self.positions[i] |
|
299 | 317 | last_cut = cur |
|
318 | ||
|
319 | # Collect all contiguous entries in the buffer at the current | |
|
320 | # offset, breaking out only for added/modified items held in | |
|
321 | # extradata, or a deleted line prior to the next position. | |
|
300 | 322 | while True: |
|
301 | 323 | self.positions[i] = offset |
|
302 | 324 | i += 1 |
General Comments 0
You need to be logged in to leave comments.
Login now