Mercurial > hg
comparison mercurial/stabletailgraph/stabletailsort.py @ 50525:1a4f54574e3d
stabletailgraph: clarify naiveness of current implementation
Both the naive and the actual versions of the algorithms are going to co-exist
for the tests. This makes is clearer that this one is naive.
author | pacien <pacien.trangirard@pacien.net> |
---|---|
date | Fri, 21 Apr 2023 14:32:58 +0200 |
parents | e1496403b08c |
children | 4fd2f7ab4177 |
comparison
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 |