Mercurial > hg
comparison mercurial/narrowspec.py @ 39539:8d8e61df8259
narrowspec: validate patterns when loading and saving spec file
Patterns should be normalized and validated before being passed into
narrowspec.save(). Let's assert that by checking immediately before
writing the narrow spec file. And let's assert that patterns loaded
from the spec file also conform.
Differential Revision: https://phab.mercurial-scm.org/D4524
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 11 Sep 2018 15:28:41 -0700 |
parents | 0d572769046a |
children | 10a8472f6662 |
comparison
equal
deleted
inserted
replaced
39538:238a1480d7ad | 39539:8d8e61df8259 |
---|---|
162 includepats, excludepats, profiles = sparse.parseconfig(repo.ui, spec, | 162 includepats, excludepats, profiles = sparse.parseconfig(repo.ui, spec, |
163 'narrow') | 163 'narrow') |
164 if profiles: | 164 if profiles: |
165 raise error.Abort(_("including other spec files using '%include' is not" | 165 raise error.Abort(_("including other spec files using '%include' is not" |
166 " supported in narrowspec")) | 166 " supported in narrowspec")) |
167 | |
168 validatepatterns(includepats) | |
169 validatepatterns(excludepats) | |
170 | |
167 return includepats, excludepats | 171 return includepats, excludepats |
168 | 172 |
169 def save(repo, includepats, excludepats): | 173 def save(repo, includepats, excludepats): |
174 validatepatterns(includepats) | |
175 validatepatterns(excludepats) | |
170 spec = format(includepats, excludepats) | 176 spec = format(includepats, excludepats) |
171 repo.svfs.write(FILENAME, spec) | 177 repo.svfs.write(FILENAME, spec) |
172 | 178 |
173 def savebackup(repo, backupname): | 179 def savebackup(repo, backupname): |
174 if repository.NARROW_REQUIREMENT not in repo.requirements: | 180 if repository.NARROW_REQUIREMENT not in repo.requirements: |