Show More
@@ -179,23 +179,7 b' class branchcache(dict):' | |||
|
179 | 179 | if not bcache.validfor(repo): |
|
180 | 180 | # invalidate the cache |
|
181 | 181 | raise ValueError(r'tip differs') |
|
182 | cl = repo.changelog | |
|
183 | for line in lineiter: | |
|
184 | line = line.rstrip('\n') | |
|
185 | if not line: | |
|
186 | continue | |
|
187 | node, state, label = line.split(" ", 2) | |
|
188 | if state not in 'oc': | |
|
189 | raise ValueError(r'invalid branch state') | |
|
190 | label = encoding.tolocal(label.strip()) | |
|
191 | node = bin(node) | |
|
192 | if not cl.hasnode(node): | |
|
193 | raise ValueError( | |
|
194 | r'node %s does not exist' % pycompat.sysstr(hex(node))) | |
|
195 | bcache.setdefault(label, []).append(node) | |
|
196 | if state == 'c': | |
|
197 | bcache._closednodes.add(node) | |
|
198 | ||
|
182 | bcache.load(repo, f) | |
|
199 | 183 | except (IOError, OSError): |
|
200 | 184 | return None |
|
201 | 185 | |
@@ -214,6 +198,26 b' class branchcache(dict):' | |||
|
214 | 198 | |
|
215 | 199 | return bcache |
|
216 | 200 | |
|
201 | def load(self, repo, f): | |
|
202 | """ fully loads the branchcache by reading from the file f """ | |
|
203 | cl = repo.changelog | |
|
204 | lineiter = iter(f) | |
|
205 | for line in lineiter: | |
|
206 | line = line.rstrip('\n') | |
|
207 | if not line: | |
|
208 | continue | |
|
209 | node, state, label = line.split(" ", 2) | |
|
210 | if state not in 'oc': | |
|
211 | raise ValueError(r'invalid branch state') | |
|
212 | label = encoding.tolocal(label.strip()) | |
|
213 | node = bin(node) | |
|
214 | if not cl.hasnode(node): | |
|
215 | raise ValueError( | |
|
216 | r'node %s does not exist' % pycompat.sysstr(hex(node))) | |
|
217 | self.setdefault(label, []).append(node) | |
|
218 | if state == 'c': | |
|
219 | self._closednodes.add(node) | |
|
220 | ||
|
217 | 221 | @staticmethod |
|
218 | 222 | def _filename(repo): |
|
219 | 223 | """name of a branchcache file for a given repo or repoview""" |
General Comments 0
You need to be logged in to leave comments.
Login now