##// END OF EJS Templates
sparse: move some temporary includes functions into core...
Gregory Szorc -
r33304:3e1accab default
parent child Browse files
Show More
@@ -193,7 +193,7 b' def _setupupdates(ui):'
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 = []
@@ -503,31 +503,13 b' def _wraprepo(ui, repo):'
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
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
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()
@@ -540,7 +522,7 b' def _wraprepo(ui, repo):'
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'
@@ -639,7 +621,7 b' def debugsparse(ui, repo, *pats, **opts)'
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"))
@@ -149,3 +149,20 b' def writeconfig(repo, includes, excludes'
149 fh.write('\n')
149 fh.write('\n')
150
150
151 invalidatesignaturecache(repo)
151 invalidatesignaturecache(repo)
152
153 def readtemporaryincludes(repo):
154 raw = repo.vfs.tryread('tempsparse')
155 if not raw:
156 return set()
157
158 return set(raw.split('\n'))
159
160 def writetemporaryincludes(repo, includes):
161 repo.vfs.write('tempsparse', '\n'.join(sorted(includes)))
162 invalidatesignaturecache(repo)
163
164 def addtemporaryincludes(repo, additional):
165 includes = readtemporaryincludes(repo)
166 for i in additional:
167 includes.add(i)
168 writetemporaryincludes(repo, includes)
General Comments 0
You need to be logged in to leave comments. Login now