builddependencies: build inverse dict from forward dict
It's error-prone to keep "dependencies" and "rdependencies" in sync
(we don't do it correctly when there are multiple successors or a
node). It's easier to just create "rependencies" from "dependencies"
after it's complete.
--- a/hgext3rd/evolve/utility.py Wed Jul 25 14:21:49 2018 -0700
+++ b/hgext3rd/evolve/utility.py Wed Jul 25 14:33:48 2018 -0700
@@ -92,8 +92,6 @@
# dependencies = {3: [6], 6:[]}
# Means that: 6 has no dependency, 3 depends on 6 to be solved
dependencies = {}
- # rdependencies is the inverted dict of dependencies
- rdependencies = {r: set() for r in revs}
for r in revs:
dependencies[r] = set()
@@ -111,7 +109,13 @@
continue
if succ in revs:
dependencies[r].add(succ)
- rdependencies[succ].add(r)
+
+ # rdependencies is the inverted dict of dependencies
+ rdependencies = {r: set() for r in revs}
+ for r, deps in dependencies.items():
+ for dep in deps:
+ rdependencies[dep].add(r)
+
return dependencies, rdependencies
def _singlesuccessor(repo, p):