changeset 42404:0c0a22f5b0b5

narrowspec: use vfs.tryread() instead of reimplementing Note that parseconfig() works well with empty strings. Differential Revision: https://phab.mercurial-scm.org/D6465
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 31 May 2019 09:25:51 -0700
parents 4ce7cdd78da3
children 0c72eddb4be5
files mercurial/narrowspec.py
diffstat 1 files changed, 3 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/narrowspec.py	Fri May 31 13:25:28 2019 -0700
+++ b/mercurial/narrowspec.py	Fri May 31 09:25:51 2019 -0700
@@ -7,8 +7,6 @@
 
 from __future__ import absolute_import
 
-import errno
-
 from .i18n import _
 from . import (
     error,
@@ -145,15 +143,9 @@
     return includepats, excludepats
 
 def load(repo):
-    try:
-        spec = repo.svfs.read(FILENAME)
-    except IOError as e:
-        # Treat "narrowspec does not exist" the same as "narrowspec file exists
-        # and is empty".
-        if e.errno == errno.ENOENT:
-            return set(), set()
-        raise
-
+    # Treat "narrowspec does not exist" the same as "narrowspec file exists
+    # and is empty".
+    spec = repo.svfs.tryread(FILENAME)
     return parseconfig(repo.ui, spec)
 
 def save(repo, includepats, excludepats):