mercurial/phases.py
changeset 48913 f254fc73d956
parent 48875 6000f5b25c9b
child 48946 642e31cb55f0
equal deleted inserted replaced
48912:a0674e916fb6 48913:f254fc73d956
   217     """encode a 'phase -> nodes' mapping into a binary stream
   217     """encode a 'phase -> nodes' mapping into a binary stream
   218 
   218 
   219     The revision lists are encoded as (phase, root) pairs.
   219     The revision lists are encoded as (phase, root) pairs.
   220     """
   220     """
   221     binarydata = []
   221     binarydata = []
   222     for phase, nodes in pycompat.iteritems(phasemapping):
   222     for phase, nodes in phasemapping.items():
   223         for head in nodes:
   223         for head in nodes:
   224             binarydata.append(_fphasesentry.pack(phase, head))
   224             binarydata.append(_fphasesentry.pack(phase, head))
   225     return b''.join(binarydata)
   225     return b''.join(binarydata)
   226 
   226 
   227 
   227 
   361         cl = repo.changelog
   361         cl = repo.changelog
   362         if len(cl) >= self._loadedrevslen:
   362         if len(cl) >= self._loadedrevslen:
   363             self.invalidate()
   363             self.invalidate()
   364             self.loadphaserevs(repo)
   364             self.loadphaserevs(repo)
   365         return any(
   365         return any(
   366             revs
   366             revs for phase, revs in self.phaseroots.items() if phase != public
   367             for phase, revs in pycompat.iteritems(self.phaseroots)
       
   368             if phase != public
       
   369         )
   367         )
   370 
   368 
   371     def nonpublicphaseroots(self, repo):
   369     def nonpublicphaseroots(self, repo):
   372         # type: (localrepo.localrepository) -> Set[bytes]
   370         # type: (localrepo.localrepository) -> Set[bytes]
   373         """returns the roots of all non-public phases
   371         """returns the roots of all non-public phases
   381             self.invalidate()
   379             self.invalidate()
   382             self.loadphaserevs(repo)
   380             self.loadphaserevs(repo)
   383         return set().union(
   381         return set().union(
   384             *[
   382             *[
   385                 revs
   383                 revs
   386                 for phase, revs in pycompat.iteritems(self.phaseroots)
   384                 for phase, revs in self.phaseroots.items()
   387                 if phase != public
   385                 if phase != public
   388             ]
   386             ]
   389         )
   387         )
   390 
   388 
   391     def getrevset(self, repo, phases, subset=None):
   389     def getrevset(self, repo, phases, subset=None):
   526             self._write(f)
   524             self._write(f)
   527         finally:
   525         finally:
   528             f.close()
   526             f.close()
   529 
   527 
   530     def _write(self, fp):
   528     def _write(self, fp):
   531         for phase, roots in pycompat.iteritems(self.phaseroots):
   529         for phase, roots in self.phaseroots.items():
   532             for h in sorted(roots):
   530             for h in sorted(roots):
   533                 fp.write(b'%i %s\n' % (phase, hex(h)))
   531                 fp.write(b'%i %s\n' % (phase, hex(h)))
   534         self.dirty = False
   532         self.dirty = False
   535 
   533 
   536     def _updateroots(self, phase, newroots, tr):
   534     def _updateroots(self, phase, newroots, tr):
   610         return changes
   608         return changes
   611 
   609 
   612     def retractboundary(self, repo, tr, targetphase, nodes):
   610     def retractboundary(self, repo, tr, targetphase, nodes):
   613         oldroots = {
   611         oldroots = {
   614             phase: revs
   612             phase: revs
   615             for phase, revs in pycompat.iteritems(self.phaseroots)
   613             for phase, revs in self.phaseroots.items()
   616             if phase <= targetphase
   614             if phase <= targetphase
   617         }
   615         }
   618         if tr is None:
   616         if tr is None:
   619             phasetracking = None
   617             phasetracking = None
   620         else:
   618         else:
   688 
   686 
   689         Nothing is lost as unknown nodes only hold data for their descendants.
   687         Nothing is lost as unknown nodes only hold data for their descendants.
   690         """
   688         """
   691         filtered = False
   689         filtered = False
   692         has_node = repo.changelog.index.has_node  # to filter unknown nodes
   690         has_node = repo.changelog.index.has_node  # to filter unknown nodes
   693         for phase, nodes in pycompat.iteritems(self.phaseroots):
   691         for phase, nodes in self.phaseroots.items():
   694             missing = sorted(node for node in nodes if not has_node(node))
   692             missing = sorted(node for node in nodes if not has_node(node))
   695             if missing:
   693             if missing:
   696                 for mnode in missing:
   694                 for mnode in missing:
   697                     repo.ui.debug(
   695                     repo.ui.debug(
   698                         b'removing unknown node %s from %i-phase boundary\n'
   696                         b'removing unknown node %s from %i-phase boundary\n'
   852     """
   850     """
   853     repo = repo.unfiltered()
   851     repo = repo.unfiltered()
   854     # build list from dictionary
   852     # build list from dictionary
   855     draftroots = []
   853     draftroots = []
   856     has_node = repo.changelog.index.has_node  # to filter unknown nodes
   854     has_node = repo.changelog.index.has_node  # to filter unknown nodes
   857     for nhex, phase in pycompat.iteritems(roots):
   855     for nhex, phase in roots.items():
   858         if nhex == b'publishing':  # ignore data related to publish option
   856         if nhex == b'publishing':  # ignore data related to publish option
   859             continue
   857             continue
   860         node = bin(nhex)
   858         node = bin(nhex)
   861         phase = int(phase)
   859         phase = int(phase)
   862         if phase == public:
   860         if phase == public: