comparison mercurial/store.py @ 41973:d7ef84e595f8

store: move logic to check for invalid entry in fncache to own function This helps separate the original reading logic from the one which finds for an invalid entry. Differential Revision: https://phab.mercurial-scm.org/D6030
author Pulkit Goyal <pulkit@yandex-team.ru>
date Wed, 27 Feb 2019 16:29:48 +0300
parents 6498f0e03526
children a56487081109
comparison
equal deleted inserted replaced
41972:7c86caee3323 41973:d7ef84e595f8
462 except IOError: 462 except IOError:
463 # skip nonexistent file 463 # skip nonexistent file
464 self.entries = set() 464 self.entries = set()
465 return 465 return
466 self.entries = set(decodedir(fp.read()).splitlines()) 466 self.entries = set(decodedir(fp.read()).splitlines())
467 self._checkentries(fp)
468 fp.close()
469
470 def _checkentries(self, fp):
471 """ make sure there is no empty string in entries """
467 if '' in self.entries: 472 if '' in self.entries:
468 fp.seek(0) 473 fp.seek(0)
469 for n, line in enumerate(util.iterfile(fp)): 474 for n, line in enumerate(util.iterfile(fp)):
470 if not line.rstrip('\n'): 475 if not line.rstrip('\n'):
471 t = _('invalid entry in fncache, line %d') % (n + 1) 476 t = _('invalid entry in fncache, line %d') % (n + 1)
472 raise error.Abort(t) 477 raise error.Abort(t)
473 fp.close()
474 478
475 def write(self, tr): 479 def write(self, tr):
476 if self._dirty: 480 if self._dirty:
477 assert self.entries is not None 481 assert self.entries is not None
478 self.entries = self.entries | self.addls 482 self.entries = self.entries | self.addls