This avoids reading all the file into memory if the cache turns out to be
invalid.
Details
Details
- Reviewers
durin42 - Group Reviewers
hg-reviewers - Commits
- rHG2a4bfbb52111: branchmap: load branchmap as an iterable
rHG9a800691f075: branchmap: load branchmap as an iterable
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Event Timeline
Comment Actions
def read(repo):
try: f = repo.cachevfs(_filename(repo))
- lines = f.read().split('\n')
- f.close()
- except (IOError, OSError):
- return None -
- try:
- cachekey = lines.pop(0).split(" ", 2)
+ cachekey = next(f).split(" ", 2)
Several tests fail, probably because of missed rstrip().
partial.setdefault(label, []).append(node) if state == 'c': partial._closednodes.add(node)+
+ except (IOError, OSError):
+ return None
+except Exception as inst: if repo.ui.debugflag: msg = 'invalid branchheads cache'
Missed finally: f.close()?