Patchwork D6030: store: move logic to check for invalid entry in fncache to own function

login
register
mail settings
Submitter phabricator
Date Feb. 27, 2019, 2:05 p.m.
Message ID <differential-rev-PHID-DREV-ujsqvh5lbu4zuqofxwxr-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/38950/
State Superseded
Headers show

Comments

phabricator - Feb. 27, 2019, 2:05 p.m.
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This helps separate the original reading logic from the one which finds for an
  invalid entry.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6030

AFFECTED FILES
  mercurial/store.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel
phabricator - March 7, 2019, 1:41 p.m.
pulkit added a comment.


  testing comments, please ignore

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6030

To: pulkit, #hg-reviewers
Cc: mercurial-devel
phabricator - March 7, 2019, 1:48 p.m.
pulkit added a comment.


  This review is intended for default branch.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6030

To: pulkit, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/store.py b/mercurial/store.py
--- a/mercurial/store.py
+++ b/mercurial/store.py
@@ -464,13 +464,17 @@ 
             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: