comparison mercurial/stabletailgraph/stabletailsort.py @ 50527:dc372251d4dc

stabletailgraph: extract _parents util func
author pacien <pacien.trangirard@pacien.net>
date Fri, 21 Apr 2023 16:19:32 +0200
parents 4fd2f7ab4177
children 8fb3e942473a
comparison
equal deleted inserted replaced
50526:4fd2f7ab4177 50527:dc372251d4dc
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 _parents(cl, rev):
78 p1, p2 = _nonoedipal_parent_revs(cl, rev)
79 if p2 == nullrev:
80 return p1, p2
81
82 return _sorted_parents(cl, p1, p2)
83
84
77 def _stable_tail_sort_naive(cl, head_rev): 85 def _stable_tail_sort_naive(cl, head_rev):
78 """ 86 """
79 Naive topological iterator of the ancestors given by the stable-tail sort. 87 Naive topological iterator of the ancestors given by the stable-tail sort.
80 88
81 The stable-tail sort of a node "h" is defined as the sequence: 89 The stable-tail sort of a node "h" is defined as the sequence:
89 """ 97 """
90 cursor_rev = head_rev 98 cursor_rev = head_rev
91 while cursor_rev != nullrev: 99 while cursor_rev != nullrev:
92 yield cursor_rev 100 yield cursor_rev
93 101
94 p1, p2 = _nonoedipal_parent_revs(cl, cursor_rev) 102 px, pt = _parents(cl, cursor_rev)
95 if p1 == nullrev: 103 if pt == nullrev:
96 cursor_rev = p2 104 cursor_rev = px
97 elif p2 == nullrev:
98 cursor_rev = p1
99 else: 105 else:
100 px, pt = _sorted_parents(cl, p1, p2)
101
102 tail_ancestors = ancestor.lazyancestors( 106 tail_ancestors = ancestor.lazyancestors(
103 cl.parentrevs, (pt,), inclusive=True 107 cl.parentrevs, (pt,), inclusive=True
104 ) 108 )
105 exclusive_ancestors = ( 109 exclusive_ancestors = (
106 a 110 a