mercurial/obsolete.py
changeset 18984 efef056b1ae9
parent 18904 e9331e979d7a
child 19053 f74f2a4e3327
equal deleted inserted replaced
18983:31bcc5112191 18984:efef056b1ae9
   402                 continue
   402                 continue
   403             for suc in mark[1]:
   403             for suc in mark[1]:
   404                 if suc not in seen:
   404                 if suc not in seen:
   405                     seen.add(suc)
   405                     seen.add(suc)
   406                     remaining.add(suc)
   406                     remaining.add(suc)
       
   407 
       
   408 def foreground(repo, nodes):
       
   409     """return all nodes in the "foreground" of other node
       
   410 
       
   411     The foreground of a revision is anything reachable using parent -> children
       
   412     or precursor -> sucessor relation. It is very similars to "descendant" but
       
   413     augmented with obsolescence information.
       
   414 
       
   415     Beware that possible obsolescence cycle may result if complexe situation.
       
   416     """
       
   417     repo = repo.unfiltered()
       
   418     foreground = set(repo.set('%ln::', nodes))
       
   419     if repo.obsstore:
       
   420         # We only need this complicated logic if there is obsolescence
       
   421         # XXX will probably deserve an optimised revset.
       
   422         nm = repo.changelog.nodemap
       
   423         plen = -1
       
   424         # compute the whole set of successors or descendants
       
   425         while len(foreground) != plen:
       
   426             plen = len(foreground)
       
   427             succs = set(c.node() for c in foreground)
       
   428             mutable = [c.node() for c in foreground if c.mutable()]
       
   429             succs.update(allsuccessors(repo.obsstore, mutable))
       
   430             known = (n for n in succs if n in nm)
       
   431             foreground = set(repo.set('%ln::', known))
       
   432     return set(c.node() for c in foreground)
       
   433 
   407 
   434 
   408 def successorssets(repo, initialnode, cache=None):
   435 def successorssets(repo, initialnode, cache=None):
   409     """Return all set of successors of initial nodes
   436     """Return all set of successors of initial nodes
   410 
   437 
   411     Successors set of changeset A are a group of revision that succeed A. It
   438     Successors set of changeset A are a group of revision that succeed A. It