# HG changeset patch # User Pulkit Goyal # Date 2019-02-27 13:29:48 # Node ID d7ef84e595f8e0332cec7baae56d999b04f50f12 # Parent 7c86caee3323327f936c0bd3067de37c8394893a 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 diff --git a/mercurial/store.py b/mercurial/store.py --- a/mercurial/store.py +++ b/mercurial/store.py @@ -464,13 +464,17 @@ class fncache(object): self.entries = set() return self.entries = set(decodedir(fp.read()).splitlines()) + self._checkentries(fp) + fp.close() + + def _checkentries(self, fp): + """ make sure there is no empty string in entries """ if '' in self.entries: fp.seek(0) for n, line in enumerate(util.iterfile(fp)): if not line.rstrip('\n'): t = _('invalid entry in fncache, line %d') % (n + 1) raise error.Abort(t) - fp.close() def write(self, tr): if self._dirty: