changeset 3906:f2cde417a738

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.
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 25 Jul 2018 16:12:01 -0700
parents 4806d1339c30
children 2af10d0a59e0
files hgext3rd/evolve/utility.py
diffstat 1 files changed, 9 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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