# HG changeset patch # User pacien # Date 1682086772 -7200 # Node ID dc372251d4dce4be9d7bb80347c8eb64447e77e5 # Parent 4fd2f7ab4177f0b3dedc99319fe090ab8f2883c3 stabletailgraph: extract _parents util func diff -r 4fd2f7ab4177 -r dc372251d4dc mercurial/stabletailgraph/stabletailsort.py --- a/mercurial/stabletailgraph/stabletailsort.py Mon May 22 19:04:05 2023 +0200 +++ b/mercurial/stabletailgraph/stabletailsort.py Fri Apr 21 16:19:32 2023 +0200 @@ -74,6 +74,14 @@ return p1, p2 +def _parents(cl, rev): + p1, p2 = _nonoedipal_parent_revs(cl, rev) + if p2 == nullrev: + return p1, p2 + + return _sorted_parents(cl, p1, p2) + + def _stable_tail_sort_naive(cl, head_rev): """ Naive topological iterator of the ancestors given by the stable-tail sort. @@ -91,14 +99,10 @@ while cursor_rev != nullrev: yield cursor_rev - p1, p2 = _nonoedipal_parent_revs(cl, cursor_rev) - if p1 == nullrev: - cursor_rev = p2 - elif p2 == nullrev: - cursor_rev = p1 + px, pt = _parents(cl, cursor_rev) + if pt == nullrev: + cursor_rev = px else: - px, pt = _sorted_parents(cl, p1, p2) - tail_ancestors = ancestor.lazyancestors( cl.parentrevs, (pt,), inclusive=True )