mercurial/obsutil.py
changeset 33252 53b3a1968aa6
parent 33149 a14e2e7f7d1f
child 33272 df90f4d6c609
equal deleted inserted replaced
33251:a5cb2e4460de 33252:53b3a1968aa6
     4 #
     4 #
     5 # This software may be used and distributed according to the terms of the
     5 # This software may be used and distributed according to the terms of the
     6 # GNU General Public License version 2 or any later version.
     6 # GNU General Public License version 2 or any later version.
     7 
     7 
     8 from __future__ import absolute_import
     8 from __future__ import absolute_import
       
     9 
       
    10 from . import (
       
    11     phases,
       
    12 )
     9 
    13 
    10 class marker(object):
    14 class marker(object):
    11     """Wrap obsolete marker raw data"""
    15     """Wrap obsolete marker raw data"""
    12 
    16 
    13     def __init__(self, repo, data):
    17     def __init__(self, repo, data):
   282             mutable = [c.node() for c in foreground if c.mutable()]
   286             mutable = [c.node() for c in foreground if c.mutable()]
   283             succs.update(allsuccessors(repo.obsstore, mutable))
   287             succs.update(allsuccessors(repo.obsstore, mutable))
   284             known = (n for n in succs if n in nm)
   288             known = (n for n in succs if n in nm)
   285             foreground = set(repo.set('%ln::', known))
   289             foreground = set(repo.set('%ln::', known))
   286     return set(c.node() for c in foreground)
   290     return set(c.node() for c in foreground)
       
   291 
       
   292 def getobsoleted(repo, tr):
       
   293     """return the set of pre-existing revisions obsoleted by a transaction"""
       
   294     torev = repo.unfiltered().changelog.nodemap.get
       
   295     phase = repo._phasecache.phase
       
   296     succsmarkers = repo.obsstore.successors.get
       
   297     public = phases.public
       
   298     addedmarkers = tr.changes.get('obsmarkers')
       
   299     addedrevs = tr.changes.get('revs')
       
   300     seenrevs = set(addedrevs)
       
   301     obsoleted = set()
       
   302     for mark in addedmarkers:
       
   303         node = mark[0]
       
   304         rev = torev(node)
       
   305         if rev is None or rev in seenrevs:
       
   306             continue
       
   307         seenrevs.add(rev)
       
   308         if phase(repo, rev) == public:
       
   309             continue
       
   310         if set(succsmarkers(node)).issubset(addedmarkers):
       
   311             obsoleted.add(rev)
       
   312     return obsoleted
   287 
   313 
   288 def successorssets(repo, initialnode, cache=None):
   314 def successorssets(repo, initialnode, cache=None):
   289     """Return set of all latest successors of initial nodes
   315     """Return set of all latest successors of initial nodes
   290 
   316 
   291     The successors set of a changeset A are the group of revisions that succeed
   317     The successors set of a changeset A are the group of revisions that succeed