Show More
@@ -346,10 +346,8 b' def applyacl_narrow(repo, kwargs):' | |||
|
346 | 346 | req_includes = set(kwargs.get('includepats', [])) |
|
347 | 347 | req_excludes = set(kwargs.get('excludepats', [])) |
|
348 | 348 | |
|
349 | invalid_includes = [] | |
|
350 |
req_includes, req_excludes |
|
|
351 | req_includes, req_excludes, | |
|
352 | user_includes, user_excludes, invalid_includes) | |
|
349 | req_includes, req_excludes, invalid_includes = narrowspec.restrictpatterns( | |
|
350 | req_includes, req_excludes, user_includes, user_excludes) | |
|
353 | 351 | |
|
354 | 352 | if invalid_includes: |
|
355 | 353 | raise error.Abort( |
@@ -134,7 +134,7 b' def archivenarrowcmd(orig, ui, repo, *ar' | |||
|
134 | 134 | repo_includes, repo_excludes = repo.narrowpats |
|
135 | 135 | includes = set(opts.get('include', [])) |
|
136 | 136 | excludes = set(opts.get('exclude', [])) |
|
137 | includes, excludes = narrowspec.restrictpatterns( | |
|
137 | includes, excludes, unused_invalid = narrowspec.restrictpatterns( | |
|
138 | 138 | includes, excludes, repo_includes, repo_excludes) |
|
139 | 139 | if includes: |
|
140 | 140 | opts['include'] = includes |
@@ -153,8 +153,7 b' def save(repo, includepats, excludepats)' | |||
|
153 | 153 | repo = share._getsrcrepo(repo) |
|
154 | 154 | repo.vfs.write(FILENAME, spec) |
|
155 | 155 | |
|
156 |
def restrictpatterns(req_includes, req_excludes, repo_includes, repo_excludes |
|
|
157 | invalid_includes=None): | |
|
156 | def restrictpatterns(req_includes, req_excludes, repo_includes, repo_excludes): | |
|
158 | 157 | r""" Restricts the patterns according to repo settings, |
|
159 | 158 | results in a logical AND operation |
|
160 | 159 | |
@@ -162,26 +161,26 b' def restrictpatterns(req_includes, req_e' | |||
|
162 | 161 | :param req_excludes: requested excludes |
|
163 | 162 | :param repo_includes: repo includes |
|
164 | 163 | :param repo_excludes: repo excludes |
|
165 | :param invalid_includes: an array to collect invalid includes | |
|
166 | :return: include and exclude patterns | |
|
164 | :return: include patterns, exclude patterns, and invalid include patterns. | |
|
167 | 165 | |
|
168 | 166 | >>> restrictpatterns({'f1','f2'}, {}, ['f1'], []) |
|
169 | (set(['f1']), {}) | |
|
167 | (set(['f1']), {}, []) | |
|
170 | 168 | >>> restrictpatterns({'f1'}, {}, ['f1','f2'], []) |
|
171 | (set(['f1']), {}) | |
|
169 | (set(['f1']), {}, []) | |
|
172 | 170 | >>> restrictpatterns({'f1/fc1', 'f3/fc3'}, {}, ['f1','f2'], []) |
|
173 | (set(['f1/fc1']), {}) | |
|
171 | (set(['f1/fc1']), {}, []) | |
|
174 | 172 | >>> restrictpatterns({'f1_fc1'}, {}, ['f1','f2'], []) |
|
175 | ([], set(['path:.'])) | |
|
173 | ([], set(['path:.']), []) | |
|
176 | 174 | >>> restrictpatterns({'f1/../f2/fc2'}, {}, ['f1','f2'], []) |
|
177 | (set(['f2/fc2']), {}) | |
|
175 | (set(['f2/fc2']), {}, []) | |
|
178 | 176 | >>> restrictpatterns({'f1/../f3/fc3'}, {}, ['f1','f2'], []) |
|
179 | ([], set(['path:.'])) | |
|
177 | ([], set(['path:.']), []) | |
|
180 | 178 | >>> restrictpatterns({'f1/$non_exitent_var'}, {}, ['f1','f2'], []) |
|
181 | (set(['f1/$non_exitent_var']), {}) | |
|
179 | (set(['f1/$non_exitent_var']), {}, []) | |
|
182 | 180 | """ |
|
183 | 181 | res_excludes = set(req_excludes) |
|
184 | 182 | res_excludes.update(repo_excludes) |
|
183 | invalid_includes = [] | |
|
185 | 184 | if not req_includes: |
|
186 | 185 | res_includes = set(repo_includes) |
|
187 | 186 | elif 'path:.' not in repo_includes: |
@@ -197,7 +196,7 b' def restrictpatterns(req_includes, req_e' | |||
|
197 | 196 | valid = True |
|
198 | 197 | res_includes.append(req_include) |
|
199 | 198 | break |
|
200 |
if not valid |
|
|
199 | if not valid: | |
|
201 | 200 | invalid_includes.append(req_include) |
|
202 | 201 | if len(res_includes) == 0: |
|
203 | 202 | res_excludes = {'path:.'} |
@@ -205,4 +204,4 b' def restrictpatterns(req_includes, req_e' | |||
|
205 | 204 | res_includes = set(res_includes) |
|
206 | 205 | else: |
|
207 | 206 | res_includes = set(req_includes) |
|
208 | return res_includes, res_excludes | |
|
207 | return res_includes, res_excludes, invalid_includes |
General Comments 0
You need to be logged in to leave comments.
Login now