mercurial/stabletailgraph/stabletailsort.py
changeset 50525 1a4f54574e3d
parent 50456 e1496403b08c
child 50526 4fd2f7ab4177
equal deleted inserted replaced
50524:58adcabc295f 50525:1a4f54574e3d
    72         return p1, nullrev
    72         return p1, nullrev
    73     else:
    73     else:
    74         return p1, p2
    74         return p1, p2
    75 
    75 
    76 
    76 
    77 def _stable_tail_sort(cl, head_rev):
    77 def _stable_tail_sort_naive(cl, head_rev):
    78     """
    78     """
    79     Naive topological iterator of the ancestors given by the stable-tail sort.
    79     Naive topological iterator of the ancestors given by the stable-tail sort.
    80 
    80 
    81     The stable-tail sort of a node "h" is defined as the sequence:
    81     The stable-tail sort of a node "h" is defined as the sequence:
    82     sts(h) := [h] + excl(h) + sts(pt(h))
    82     sts(h) := [h] + excl(h) + sts(pt(h))
   101 
   101 
   102             tail_ancestors = ancestor.lazyancestors(
   102             tail_ancestors = ancestor.lazyancestors(
   103                 cl.parentrevs, (pt,), inclusive=True
   103                 cl.parentrevs, (pt,), inclusive=True
   104             )
   104             )
   105             exclusive_ancestors = (
   105             exclusive_ancestors = (
   106                 a for a in _stable_tail_sort(cl, px) if a not in tail_ancestors
   106                 a
       
   107                 for a in _stable_tail_sort_naive(cl, px)
       
   108                 if a not in tail_ancestors
   107             )
   109             )
   108 
   110 
   109             excl_part_size = cl.fast_rank(cursor_rev) - cl.fast_rank(pt) - 1
   111             excl_part_size = cl.fast_rank(cursor_rev) - cl.fast_rank(pt) - 1
   110             yield from itertools.islice(exclusive_ancestors, excl_part_size)
   112             yield from itertools.islice(exclusive_ancestors, excl_part_size)
   111             cursor_rev = pt
   113             cursor_rev = pt