mercurial/revset.py
changeset 33075 d83b189aef83
parent 33003 f63d111258da
child 33080 a53bfc2845f2
equal deleted inserted replaced
33074:e999b59d6eb1 33075:d83b189aef83
   598 def _descendants(repo, subset, x, followfirst=False):
   598 def _descendants(repo, subset, x, followfirst=False):
   599     roots = getset(repo, fullreposet(repo), x)
   599     roots = getset(repo, fullreposet(repo), x)
   600     if not roots:
   600     if not roots:
   601         return baseset()
   601         return baseset()
   602     s = dagop.revdescendants(repo, roots, followfirst)
   602     s = dagop.revdescendants(repo, roots, followfirst)
   603 
   603     return subset & s
   604     # Both sets need to be ascending in order to lazily return the union
       
   605     # in the correct order.
       
   606     base = subset & roots
       
   607     desc = subset & s
       
   608     result = base + desc
       
   609     if subset.isascending():
       
   610         result.sort()
       
   611     elif subset.isdescending():
       
   612         result.sort(reverse=True)
       
   613     else:
       
   614         result = subset & result
       
   615     return result
       
   616 
   604 
   617 @predicate('descendants(set)', safe=True)
   605 @predicate('descendants(set)', safe=True)
   618 def descendants(repo, subset, x):
   606 def descendants(repo, subset, x):
   619     """Changesets which are descendants of changesets in set, including the
   607     """Changesets which are descendants of changesets in set, including the
   620     given changesets themselves.
   608     given changesets themselves.