builddependencies: share code between single- and multi-successor cases
authorMartin von Zweigbergk <martinvonz@google.com>
Wed, 25 Jul 2018 16:23:25 -0700
changeset 3905 4806d1339c30
parent 3904 d2d03df3956f
child 3906 f2cde417a738
builddependencies: share code between single- and multi-successor cases The two cases now have more similar structure ("if succ in revs: dependencies[r].add(succ)"), so let's share the code so it doesn't start drifting apart again.
hgext3rd/evolve/utility.py
--- a/hgext3rd/evolve/utility.py	Wed Jul 25 14:33:48 2018 -0700
+++ b/hgext3rd/evolve/utility.py	Wed Jul 25 16:23:25 2018 -0700
@@ -97,18 +97,15 @@
         dependencies[r] = set()
         for p in repo[r].parents():
             try:
-                succ = _singlesuccessor(repo, p)
+                succs = {_singlesuccessor(repo, p)}
             except MultipleSuccessorsError as exc:
-                tset = set()
+                succs = set()
                 for successorsset in exc.successorssets:
                     for node in successorsset:
-                        succ = repo[node].rev()
-                        if succ in revs:
-                            tset.add(succ)
-                dependencies[r].update(tset)
-                continue
-            if succ in revs:
-                dependencies[r].add(succ)
+                        succs.add(repo[node].rev())
+            for succ in succs:
+                if succ in revs:
+                    dependencies[r].add(succ)
 
     # rdependencies is the inverted dict of dependencies
     rdependencies = {r: set() for r in revs}