Mercurial > hg
comparison mercurial/narrowspec.py @ 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 | 84bd6ae2d1f6 |
children | 4738c292a520 |
comparison
equal
deleted
inserted
replaced
42403:4ce7cdd78da3 | 42404:0c0a22f5b0b5 |
---|---|
4 # | 4 # |
5 # This software may be used and distributed according to the terms of the | 5 # This software may be used and distributed according to the terms of the |
6 # GNU General Public License version 2 or any later version. | 6 # GNU General Public License version 2 or any later version. |
7 | 7 |
8 from __future__ import absolute_import | 8 from __future__ import absolute_import |
9 | |
10 import errno | |
11 | 9 |
12 from .i18n import _ | 10 from .i18n import _ |
13 from . import ( | 11 from . import ( |
14 error, | 12 error, |
15 match as matchmod, | 13 match as matchmod, |
143 validatepatterns(excludepats) | 141 validatepatterns(excludepats) |
144 | 142 |
145 return includepats, excludepats | 143 return includepats, excludepats |
146 | 144 |
147 def load(repo): | 145 def load(repo): |
148 try: | 146 # Treat "narrowspec does not exist" the same as "narrowspec file exists |
149 spec = repo.svfs.read(FILENAME) | 147 # and is empty". |
150 except IOError as e: | 148 spec = repo.svfs.tryread(FILENAME) |
151 # Treat "narrowspec does not exist" the same as "narrowspec file exists | |
152 # and is empty". | |
153 if e.errno == errno.ENOENT: | |
154 return set(), set() | |
155 raise | |
156 | |
157 return parseconfig(repo.ui, spec) | 149 return parseconfig(repo.ui, spec) |
158 | 150 |
159 def save(repo, includepats, excludepats): | 151 def save(repo, includepats, excludepats): |
160 validatepatterns(includepats) | 152 validatepatterns(includepats) |
161 validatepatterns(excludepats) | 153 validatepatterns(excludepats) |