comparison mercurial/repoview.py @ 27917:97e0dc6d248c stable

repoview: fix corrupted hiddencache crash Mercurial (issue5042) Before this patch if the hiddencache existed but was empty, it would crash mercurial. This patch adds exception handling when reading the hiddencache to avoid the issue. When encountering a corrupted cache file we print a devel warning. There would be no point in issuing a normal warning as the user wouldn't be able to do anything about the situation. The warning looks like: devel-warn: corrupted hidden cache, removing it at: /path/to/repoview.py
author Laurent Charignon <lcharignon@fb.com>
date Wed, 20 Jan 2016 13:43:01 -0800
parents 9a09a9cfa503
children 332926212ef8
comparison
equal deleted inserted replaced
27916:9a09a9cfa503 27917:97e0dc6d248c
148 # cache is valid, so we can start reading the hidden revs 148 # cache is valid, so we can start reading the hidden revs
149 data = fh.read() 149 data = fh.read()
150 count = len(data) / 4 150 count = len(data) / 4
151 hidden = frozenset(struct.unpack('>%ii' % count, data)) 151 hidden = frozenset(struct.unpack('>%ii' % count, data))
152 return hidden 152 return hidden
153 except struct.error:
154 repo.ui.debug('corrupted hidden cache\n')
155 # No need to fix the content as it will get rewritten
156 return None
157 except (IOError, OSError):
158 repo.ui.debug('cannot read hidden cache\n')
159 return None
153 finally: 160 finally:
154 if fh: 161 if fh:
155 fh.close() 162 fh.close()
156 163
157 def computehidden(repo): 164 def computehidden(repo):