Mercurial > public > mercurial-scm > hg
comparison mercurial/branchmap.py @ 41808:8ad46ac6728e
branchmap: prevent reading the file twice through different iterators
Otherwise, test-static-http.t breaks.
Differential Revision: https://phab.mercurial-scm.org/D6028
author | Pulkit Goyal <pulkit@yandex-team.ru> |
---|---|
date | Tue, 26 Feb 2019 17:26:33 +0300 |
parents | 68bbcc70e274 |
children | 38de3300414f |
comparison
equal
deleted
inserted
replaced
41807:941685500125 | 41808:8ad46ac6728e |
---|---|
177 filteredhash = bin(cachekey[2]) | 177 filteredhash = bin(cachekey[2]) |
178 bcache = cls(tipnode=last, tiprev=lrev, filteredhash=filteredhash) | 178 bcache = cls(tipnode=last, tiprev=lrev, filteredhash=filteredhash) |
179 if not bcache.validfor(repo): | 179 if not bcache.validfor(repo): |
180 # invalidate the cache | 180 # invalidate the cache |
181 raise ValueError(r'tip differs') | 181 raise ValueError(r'tip differs') |
182 bcache.load(repo, f) | 182 bcache.load(repo, lineiter) |
183 except (IOError, OSError): | 183 except (IOError, OSError): |
184 return None | 184 return None |
185 | 185 |
186 except Exception as inst: | 186 except Exception as inst: |
187 if repo.ui.debugflag: | 187 if repo.ui.debugflag: |
196 if f: | 196 if f: |
197 f.close() | 197 f.close() |
198 | 198 |
199 return bcache | 199 return bcache |
200 | 200 |
201 def load(self, repo, f): | 201 def load(self, repo, lineiter): |
202 """ fully loads the branchcache by reading from the file f """ | 202 """ fully loads the branchcache by reading from the file using the line |
203 iterator passed""" | |
203 cl = repo.changelog | 204 cl = repo.changelog |
204 lineiter = iter(f) | |
205 for line in lineiter: | 205 for line in lineiter: |
206 line = line.rstrip('\n') | 206 line = line.rstrip('\n') |
207 if not line: | 207 if not line: |
208 continue | 208 continue |
209 node, state, label = line.split(" ", 2) | 209 node, state, label = line.split(" ", 2) |