Mercurial > public > mercurial-scm > hg
comparison mercurial/sparse.py @ 33325:38df146d0697
sparse: inline signature cache clearing
It is a trivial one-liner. No need to have a separate function.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 06 Jul 2017 16:10:28 -0700 |
parents | 33d0859c37bd |
children | 160efb559f67 |
comparison
equal
deleted
inserted
replaced
33324:33d0859c37bd | 33325:38df146d0697 |
---|---|
132 for rev in revs: | 132 for rev in revs: |
133 profiles.update(patternsforrev(repo, rev)[2]) | 133 profiles.update(patternsforrev(repo, rev)[2]) |
134 | 134 |
135 return profiles | 135 return profiles |
136 | 136 |
137 def invalidatesignaturecache(repo): | |
138 repo._sparsesignaturecache.clear() | |
139 | |
140 def configsignature(repo, includetemp=True): | 137 def configsignature(repo, includetemp=True): |
141 """Obtain the signature string for the current sparse configuration. | 138 """Obtain the signature string for the current sparse configuration. |
142 | 139 |
143 This is used to construct a cache key for matchers. | 140 This is used to construct a cache key for matchers. |
144 """ | 141 """ |
178 fh.write('[exclude]\n') | 175 fh.write('[exclude]\n') |
179 for e in sorted(excludes): | 176 for e in sorted(excludes): |
180 fh.write(e) | 177 fh.write(e) |
181 fh.write('\n') | 178 fh.write('\n') |
182 | 179 |
183 invalidatesignaturecache(repo) | 180 repo._sparsesignaturecache.clear() |
184 | 181 |
185 def readtemporaryincludes(repo): | 182 def readtemporaryincludes(repo): |
186 raw = repo.vfs.tryread('tempsparse') | 183 raw = repo.vfs.tryread('tempsparse') |
187 if not raw: | 184 if not raw: |
188 return set() | 185 return set() |
189 | 186 |
190 return set(raw.split('\n')) | 187 return set(raw.split('\n')) |
191 | 188 |
192 def writetemporaryincludes(repo, includes): | 189 def writetemporaryincludes(repo, includes): |
193 repo.vfs.write('tempsparse', '\n'.join(sorted(includes))) | 190 repo.vfs.write('tempsparse', '\n'.join(sorted(includes))) |
194 invalidatesignaturecache(repo) | 191 repo._sparsesignaturecache.clear() |
195 | 192 |
196 def addtemporaryincludes(repo, additional): | 193 def addtemporaryincludes(repo, additional): |
197 includes = readtemporaryincludes(repo) | 194 includes = readtemporaryincludes(repo) |
198 for i in additional: | 195 for i in additional: |
199 includes.add(i) | 196 includes.add(i) |
227 # Fix dirstate | 224 # Fix dirstate |
228 for file in dropped: | 225 for file in dropped: |
229 dirstate.drop(file) | 226 dirstate.drop(file) |
230 | 227 |
231 repo.vfs.unlink('tempsparse') | 228 repo.vfs.unlink('tempsparse') |
232 invalidatesignaturecache(repo) | 229 repo._sparsesignaturecache.clear() |
233 msg = _('cleaned up %d temporarily added file(s) from the ' | 230 msg = _('cleaned up %d temporarily added file(s) from the ' |
234 'sparse checkout\n') | 231 'sparse checkout\n') |
235 repo.ui.status(msg % len(tempincludes)) | 232 repo.ui.status(msg % len(tempincludes)) |
236 | 233 |
237 def matcher(repo, revs=None, includetemp=True): | 234 def matcher(repo, revs=None, includetemp=True): |