##// END OF EJS Templates
phases: do filtering at read time...
marmoute -
r52298:12881244 default
parent child Browse files
Show More
@@ -210,12 +210,20 b' def _readroots('
210 repo = repo.unfiltered()
210 repo = repo.unfiltered()
211 dirty = False
211 dirty = False
212 roots = {i: set() for i in allphases}
212 roots = {i: set() for i in allphases}
213 has_node = repo.changelog.index.has_node
214 unknown_msg = b'removing unknown node %s from %i-phase boundary\n'
213 try:
215 try:
214 f, pending = txnutil.trypending(repo.root, repo.svfs, b'phaseroots')
216 f, pending = txnutil.trypending(repo.root, repo.svfs, b'phaseroots')
215 try:
217 try:
216 for line in f:
218 for line in f:
217 phase, nh = line.split()
219 str_phase, hex_node = line.split()
218 roots[int(phase)].add(bin(nh))
220 phase = int(str_phase)
221 node = bin(hex_node)
222 if not has_node(node):
223 repo.ui.debug(unknown_msg % (short(hex_node), phase))
224 dirty = True
225 else:
226 roots[phase].add(node)
219 finally:
227 finally:
220 f.close()
228 f.close()
221 except FileNotFoundError:
229 except FileNotFoundError:
@@ -364,10 +372,11 b' class phasecache:'
364 ):
372 ):
365 if _load:
373 if _load:
366 # Cheap trick to allow shallow-copy without copy module
374 # Cheap trick to allow shallow-copy without copy module
367 self._phaseroots, self.dirty = _readroots(repo, phasedefaults)
375 loaded = _readroots(repo, phasedefaults)
376 self._phaseroots: Phaseroots = loaded[0]
377 self.dirty: bool = loaded[1]
368 self._loadedrevslen = 0
378 self._loadedrevslen = 0
369 self._phasesets = None
379 self._phasesets = None
370 self.filterunknown(repo)
371
380
372 def hasnonpublicphases(self, repo: "localrepo.localrepository") -> bool:
381 def hasnonpublicphases(self, repo: "localrepo.localrepository") -> bool:
373 """detect if there are revisions with non-public phase"""
382 """detect if there are revisions with non-public phase"""
@@ -730,35 +739,6 b' class phasecache:'
730 self._updateroots(repo, targetphase, nodes - filtered, tr)
739 self._updateroots(repo, targetphase, nodes - filtered, tr)
731 self.invalidate()
740 self.invalidate()
732
741
733 def filterunknown(self, repo: "localrepo.localrepository") -> None:
734 """remove unknown nodes from the phase boundary
735
736 Nothing is lost as unknown nodes only hold data for their descendants.
737 """
738 filtered = False
739 has_node = repo.changelog.index.has_node # to filter unknown nodes
740 for phase, nodes in self._phaseroots.items():
741 missing = sorted(node for node in nodes if not has_node(node))
742 if missing:
743 for mnode in missing:
744 repo.ui.debug(
745 b'removing unknown node %s from %i-phase boundary\n'
746 % (short(mnode), phase)
747 )
748 nodes.symmetric_difference_update(missing)
749 filtered = True
750 if filtered:
751 self.dirty = True
752 # filterunknown is called by repo.destroyed, we may have no changes in
753 # root but _phasesets contents is certainly invalid (or at least we
754 # have not proper way to check that). related to issue 3858.
755 #
756 # The other caller is __init__ that have no _phasesets initialized
757 # anyway. If this change we should consider adding a dedicated
758 # "destroyed" function to phasecache or a proper cache key mechanism
759 # (see branchmap one)
760 self.invalidate()
761
762
742
763 def advanceboundary(repo, tr, targetphase, nodes, revs=None, dryrun=None):
743 def advanceboundary(repo, tr, targetphase, nodes, revs=None, dryrun=None):
764 """Add nodes to a phase changing other nodes phases if necessary.
744 """Add nodes to a phase changing other nodes phases if necessary.
General Comments 0
You need to be logged in to leave comments. Login now