stabletailgraph: extract _parents util func
authorpacien <pacien.trangirard@pacien.net>
Fri, 21 Apr 2023 16:19:32 +0200
changeset 50527 dc372251d4dc
parent 50526 4fd2f7ab4177
child 50528 8fb3e942473a
stabletailgraph: extract _parents util func
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
             )