Mercurial > hg
comparison hgext/sparse.py @ 33304:3e1accab7447
sparse: move some temporary includes functions into core
Functions for reading and writing the tempsparse file have been
moved. prunetemporaryincludes() will be moved separately
because it is non-trivial.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 06 Jul 2017 14:48:16 -0700 |
parents | 8b571495d811 |
children | d2d4b210a040 |
comparison
equal
deleted
inserted
replaced
33303:8b571495d811 | 33304:3e1accab7447 |
---|---|
191 prunedactions[file] = ('r', args, msg) | 191 prunedactions[file] = ('r', args, msg) |
192 | 192 |
193 if len(temporaryfiles) > 0: | 193 if len(temporaryfiles) > 0: |
194 ui.status(_("temporarily included %d file(s) in the sparse checkout" | 194 ui.status(_("temporarily included %d file(s) in the sparse checkout" |
195 " for merging\n") % len(temporaryfiles)) | 195 " for merging\n") % len(temporaryfiles)) |
196 repo.addtemporaryincludes(temporaryfiles) | 196 sparse.addtemporaryincludes(repo, temporaryfiles) |
197 | 197 |
198 # Add the new files to the working copy so they can be merged, etc | 198 # Add the new files to the working copy so they can be merged, etc |
199 actions = [] | 199 actions = [] |
200 message = 'temporarily adding to sparse checkout' | 200 message = 'temporarily adding to sparse checkout' |
201 wctxmanifest = repo[None].manifest() | 201 wctxmanifest = repo[None].manifest() |
501 result = matchers[0] | 501 result = matchers[0] |
502 else: | 502 else: |
503 result = unionmatcher(matchers) | 503 result = unionmatcher(matchers) |
504 | 504 |
505 if kwargs.get('includetemp', True): | 505 if kwargs.get('includetemp', True): |
506 tempincludes = self.gettemporaryincludes() | 506 tempincludes = sparse.readtemporaryincludes(self) |
507 result = forceincludematcher(result, tempincludes) | 507 result = forceincludematcher(result, tempincludes) |
508 | 508 |
509 self._sparsematchercache[key] = result | 509 self._sparsematchercache[key] = result |
510 | 510 |
511 return result | 511 return result |
512 | |
513 def addtemporaryincludes(self, files): | |
514 includes = self.gettemporaryincludes() | |
515 for file in files: | |
516 includes.add(file) | |
517 self._writetemporaryincludes(includes) | |
518 | |
519 def gettemporaryincludes(self): | |
520 existingtemp = set() | |
521 raw = self.vfs.tryread('tempsparse') | |
522 if raw: | |
523 existingtemp.update(raw.split('\n')) | |
524 return existingtemp | |
525 | |
526 def _writetemporaryincludes(self, includes): | |
527 raw = '\n'.join(sorted(includes)) | |
528 self.vfs.write('tempsparse', raw) | |
529 sparse.invalidatesignaturecache(self) | |
530 | 512 |
531 def prunetemporaryincludes(self): | 513 def prunetemporaryincludes(self): |
532 if repo.vfs.exists('tempsparse'): | 514 if repo.vfs.exists('tempsparse'): |
533 origstatus = self.status() | 515 origstatus = self.status() |
534 modified, added, removed, deleted, a, b, c = origstatus | 516 modified, added, removed, deleted, a, b, c = origstatus |
538 | 520 |
539 sparsematch = self.sparsematch(includetemp=False) | 521 sparsematch = self.sparsematch(includetemp=False) |
540 dirstate = self.dirstate | 522 dirstate = self.dirstate |
541 actions = [] | 523 actions = [] |
542 dropped = [] | 524 dropped = [] |
543 tempincludes = self.gettemporaryincludes() | 525 tempincludes = sparse.readtemporaryincludes(self) |
544 for file in tempincludes: | 526 for file in tempincludes: |
545 if file in dirstate and not sparsematch(file): | 527 if file in dirstate and not sparsematch(file): |
546 message = 'dropping temporarily included sparse files' | 528 message = 'dropping temporarily included sparse files' |
547 actions.append((file, None, message)) | 529 actions.append((file, None, message)) |
548 dropped.append(file) | 530 dropped.append(file) |
637 raise error.Abort(_("too many flags specified")) | 619 raise error.Abort(_("too many flags specified")) |
638 | 620 |
639 if count == 0: | 621 if count == 0: |
640 if repo.vfs.exists('sparse'): | 622 if repo.vfs.exists('sparse'): |
641 ui.status(repo.vfs.read("sparse") + "\n") | 623 ui.status(repo.vfs.read("sparse") + "\n") |
642 temporaryincludes = repo.gettemporaryincludes() | 624 temporaryincludes = sparse.readtemporaryincludes(repo) |
643 if temporaryincludes: | 625 if temporaryincludes: |
644 ui.status(_("Temporarily Included Files (for merge/rebase):\n")) | 626 ui.status(_("Temporarily Included Files (for merge/rebase):\n")) |
645 ui.status(("\n".join(temporaryincludes) + "\n")) | 627 ui.status(("\n".join(temporaryincludes) + "\n")) |
646 else: | 628 else: |
647 ui.status(_('repo is not sparse\n')) | 629 ui.status(_('repo is not sparse\n')) |