Mercurial > public > mercurial-scm > hg-stable
diff mercurial/sparse.py @ 33354:4695f1829045
sparse: move code for clearing rules to core
This is a pretty straightforward port.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 08 Jul 2017 13:19:38 -0700 |
parents | 160efb559f67 |
children | 9087f9997f42 |
line wrap: on
line diff
--- a/mercurial/sparse.py Fri Jul 07 11:51:10 2017 -0700 +++ b/mercurial/sparse.py Sat Jul 08 13:19:38 2017 -0700 @@ -494,3 +494,21 @@ refreshwdir(repo, origstatus, origsparsematch, force=True) prunetemporaryincludes(repo) + +def clearrules(repo, force=False): + """Clears include/exclude rules from the sparse config. + + The remaining sparse config only has profiles, if defined. The working + directory is refreshed, as needed. + """ + with repo.wlock(): + raw = repo.vfs.tryread('sparse') + includes, excludes, profiles = parseconfig(repo.ui, raw) + + if not includes and not excludes: + return + + oldstatus = repo.status() + oldmatch = matcher(repo) + writeconfig(repo, set(), set(), profiles) + refreshwdir(repo, oldstatus, oldmatch, force=force)