builddependencies: extract function for getting successors
authorMartin von Zweigbergk <martinvonz@google.com>
Wed, 25 Jul 2018 16:12:01 -0700
changeset 3906 f2cde417a738
parent 3905 4806d1339c30
child 3908 2af10d0a59e0
builddependencies: extract function for getting successors The code no longer makes a difference between single- and mult-successor cases and just needs a set (or generator, really) of successors to iterate over. Let's extract that into a function.
hgext3rd/evolve/utility.py
--- a/hgext3rd/evolve/utility.py	Wed Jul 25 16:23:25 2018 -0700
+++ b/hgext3rd/evolve/utility.py	Wed Jul 25 16:12:01 2018 -0700
@@ -96,14 +96,7 @@
     for r in revs:
         dependencies[r] = set()
         for p in repo[r].parents():
-            try:
-                succs = {_singlesuccessor(repo, p)}
-            except MultipleSuccessorsError as exc:
-                succs = set()
-                for successorsset in exc.successorssets:
-                    for node in successorsset:
-                        succs.add(repo[node].rev())
-            for succ in succs:
+            for succ in _successorrevs(repo, p):
                 if succ in revs:
                     dependencies[r].add(succ)
 
@@ -137,6 +130,14 @@
 
     return repo[newer[0][0]].rev()
 
+def _successorrevs(repo, ctx):
+    try:
+        return {_singlesuccessor(repo, ctx)}
+    except MultipleSuccessorsError as exc:
+        return {repo[node].rev()
+                for successorsset in exc.successorssets
+                for node in successorsset}
+
 def revselectionprompt(ui, repo, revs, customheader=""):
     """function to prompt user to choose a revision from all the revs and return
     that revision for further tasks