equal
deleted
inserted
replaced
10 import errno |
10 import errno |
11 |
11 |
12 from .i18n import _ |
12 from .i18n import _ |
13 from . import ( |
13 from . import ( |
14 error, |
14 error, |
15 hg, |
|
16 match as matchmod, |
15 match as matchmod, |
17 util, |
16 util, |
18 ) |
17 ) |
19 |
18 |
20 FILENAME = 'narrowspec' |
19 FILENAME = 'narrowspec' |
127 |
126 |
128 def needsexpansion(includes): |
127 def needsexpansion(includes): |
129 return [i for i in includes if i.startswith('include:')] |
128 return [i for i in includes if i.startswith('include:')] |
130 |
129 |
131 def load(repo): |
130 def load(repo): |
132 if repo.shared(): |
|
133 repo = hg.sharedreposource(repo) |
|
134 try: |
131 try: |
135 spec = repo.vfs.read(FILENAME) |
132 spec = repo.vfs.read(FILENAME) |
136 except IOError as e: |
133 except IOError as e: |
137 # Treat "narrowspec does not exist" the same as "narrowspec file exists |
134 # Treat "narrowspec does not exist" the same as "narrowspec file exists |
138 # and is empty". |
135 # and is empty". |
144 raise |
141 raise |
145 return _parsestoredpatterns(spec) |
142 return _parsestoredpatterns(spec) |
146 |
143 |
147 def save(repo, includepats, excludepats): |
144 def save(repo, includepats, excludepats): |
148 spec = format(includepats, excludepats) |
145 spec = format(includepats, excludepats) |
149 if repo.shared(): |
|
150 repo = hg.sharedreposource(repo) |
|
151 repo.vfs.write(FILENAME, spec) |
146 repo.vfs.write(FILENAME, spec) |
152 |
147 |
153 def restrictpatterns(req_includes, req_excludes, repo_includes, repo_excludes): |
148 def restrictpatterns(req_includes, req_excludes, repo_includes, repo_excludes): |
154 r""" Restricts the patterns according to repo settings, |
149 r""" Restricts the patterns according to repo settings, |
155 results in a logical AND operation |
150 results in a logical AND operation |