mercurial/obsutil.py
changeset 33146 7017567ebdf2
parent 33145 0a370b93cca2
child 33148 4e30168d7939
equal deleted inserted replaced
33145:0a370b93cca2 33146:7017567ebdf2
   200             if precmarkers.issubset(exclmarkers):
   200             if precmarkers.issubset(exclmarkers):
   201                 seennodes.add(prec)
   201                 seennodes.add(prec)
   202                 stack.append(prec)
   202                 stack.append(prec)
   203 
   203 
   204     return exclmarkers
   204     return exclmarkers
       
   205 
       
   206 def foreground(repo, nodes):
       
   207     """return all nodes in the "foreground" of other node
       
   208 
       
   209     The foreground of a revision is anything reachable using parent -> children
       
   210     or precursor -> successor relation. It is very similar to "descendant" but
       
   211     augmented with obsolescence information.
       
   212 
       
   213     Beware that possible obsolescence cycle may result if complex situation.
       
   214     """
       
   215     repo = repo.unfiltered()
       
   216     foreground = set(repo.set('%ln::', nodes))
       
   217     if repo.obsstore:
       
   218         # We only need this complicated logic if there is obsolescence
       
   219         # XXX will probably deserve an optimised revset.
       
   220         nm = repo.changelog.nodemap
       
   221         plen = -1
       
   222         # compute the whole set of successors or descendants
       
   223         while len(foreground) != plen:
       
   224             plen = len(foreground)
       
   225             succs = set(c.node() for c in foreground)
       
   226             mutable = [c.node() for c in foreground if c.mutable()]
       
   227             succs.update(allsuccessors(repo.obsstore, mutable))
       
   228             known = (n for n in succs if n in nm)
       
   229             foreground = set(repo.set('%ln::', known))
       
   230     return set(c.node() for c in foreground)
   205 
   231 
   206 def successorssets(repo, initialnode, cache=None):
   232 def successorssets(repo, initialnode, cache=None):
   207     """Return set of all latest successors of initial nodes
   233     """Return set of all latest successors of initial nodes
   208 
   234 
   209     The successors set of a changeset A are the group of revisions that succeed
   235     The successors set of a changeset A are the group of revisions that succeed