mercurial/obsolete.py
changeset 17828 9495be4126ef
parent 17827 612db9d7e76a
child 17831 70b08df24fef
equal deleted inserted replaced
17827:612db9d7e76a 17828:9495be4126ef
   366             for suc in mark[1]:
   366             for suc in mark[1]:
   367                 if suc not in seen:
   367                 if suc not in seen:
   368                     seen.add(suc)
   368                     seen.add(suc)
   369                     remaining.add(suc)
   369                     remaining.add(suc)
   370 
   370 
   371 # mapping of 'set-name' -> <function to computer this set>
   371 def _knownrevs(repo, nodes):
       
   372     """yield revision numbers of known nodes passed in parameters
       
   373 
       
   374     Unknown revisions are silently ignored."""
       
   375     torev = repo.changelog.nodemap.get
       
   376     for n in nodes:
       
   377         rev = torev(n)
       
   378         if rev is not None:
       
   379             yield rev
       
   380 
       
   381 # mapping of 'set-name' -> <function to compute this set>
   372 cachefuncs = {}
   382 cachefuncs = {}
   373 def cachefor(name):
   383 def cachefor(name):
   374     """Decorator to register a function as computing the cache for a set"""
   384     """Decorator to register a function as computing the cache for a set"""
   375     def decorator(func):
   385     def decorator(func):
   376         assert name not in cachefuncs
   386         assert name not in cachefuncs
   429 
   439 
   430 @cachefor('extinct')
   440 @cachefor('extinct')
   431 def _computeextinctset(repo):
   441 def _computeextinctset(repo):
   432     """the set of obsolete parents without non obsolete descendants"""
   442     """the set of obsolete parents without non obsolete descendants"""
   433     return set(repo.revs('obsolete() - obsolete()::unstable()'))
   443     return set(repo.revs('obsolete() - obsolete()::unstable()'))
       
   444 
       
   445 
       
   446 @cachefor('bumped')
       
   447 def _computebumpedset(repo):
       
   448     """the set of revs trying to obsolete public revisions"""
       
   449     # get all possible bumped changesets
       
   450     tonode = repo.changelog.node
       
   451     publicnodes = (tonode(r) for r in repo.revs('public()'))
       
   452     successors = allsuccessors(repo.obsstore, publicnodes)
       
   453     # revision public or already obsolete don't count as bumped
       
   454     query = '%ld - obsolete() - public()'
       
   455     return set(repo.revs(query, _knownrevs(repo, successors)))
   434 
   456 
   435 def createmarkers(repo, relations, flag=0, metadata=None):
   457 def createmarkers(repo, relations, flag=0, metadata=None):
   436     """Add obsolete markers between changesets in a repo
   458     """Add obsolete markers between changesets in a repo
   437 
   459 
   438     <relations> must be an iterable of (<old>, (<new>, ...)) tuple.
   460     <relations> must be an iterable of (<old>, (<new>, ...)) tuple.