mercurial/obsolete.py
changeset 24044 e0e6dd806b23
parent 24019 26fbf07482b2
child 24045 43061f96e40e
equal deleted inserted replaced
24043:1fdb1d909c79 24044:e0e6dd806b23
   468 
   468 
   469     def flags(self):
   469     def flags(self):
   470         """The flags field of the marker"""
   470         """The flags field of the marker"""
   471         return self._data[2]
   471         return self._data[2]
   472 
   472 
       
   473 @util.nogc
       
   474 def _addsuccessors(successors, markers):
       
   475     for mark in markers:
       
   476         successors.setdefault(mark[0], set()).add(mark)
       
   477 
       
   478 @util.nogc
       
   479 def _addprecursors(precursors, markers):
       
   480     for mark in markers:
       
   481         for suc in mark[1]:
       
   482             precursors.setdefault(suc, set()).add(mark)
       
   483 
       
   484 @util.nogc
       
   485 def _addchildren(children, markers):
       
   486     for mark in markers:
       
   487         parents = mark[5]
       
   488         if parents is not None:
       
   489             for p in parents:
       
   490                 children.setdefault(p, set()).add(mark)
       
   491 
   473 def _checkinvalidmarkers(obsstore):
   492 def _checkinvalidmarkers(obsstore):
   474     """search for marker with invalid data and raise error if needed
   493     """search for marker with invalid data and raise error if needed
   475 
   494 
   476     Exist as a separated function to allow the evolve extension for a more
   495     Exist as a separated function to allow the evolve extension for a more
   477     subtle handling.
   496     subtle handling.
   602 
   621 
   603         Returns the number of new markers added."""
   622         Returns the number of new markers added."""
   604         version, markers = _readmarkers(data)
   623         version, markers = _readmarkers(data)
   605         return self.add(transaction, markers)
   624         return self.add(transaction, markers)
   606 
   625 
   607     @util.nogc
       
   608     def _load(self, markers):
   626     def _load(self, markers):
   609         for mark in markers:
   627         markers = list(markers) # to allow repeated iteration
   610             self._all.append(mark)
   628         self._all.extend(markers)
   611             pre, sucs = mark[:2]
   629         _addsuccessors(self.successors, markers)
   612             self.successors.setdefault(pre, set()).add(mark)
   630         _addprecursors(self.precursors, markers)
   613             for suc in sucs:
   631         _addchildren(self.children, markers)
   614                 self.precursors.setdefault(suc, set()).add(mark)
       
   615             parents = mark[5]
       
   616             if parents is not None:
       
   617                 for p in parents:
       
   618                     self.children.setdefault(p, set()).add(mark)
       
   619         _checkinvalidmarkers(self)
   632         _checkinvalidmarkers(self)
   620 
   633 
   621     def relevantmarkers(self, nodes):
   634     def relevantmarkers(self, nodes):
   622         """return a set of all obsolescence markers relevant to a set of nodes.
   635         """return a set of all obsolescence markers relevant to a set of nodes.
   623 
   636