diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2010-10-25 17:26:36 +0100 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2010-10-25 17:26:36 +0100 |
commit | f9f26fe6a62e009331574bd60cce22366ce48712 (patch) | |
tree | d4ac1068216cb554bbd5eed374dd46e1999427d9 | |
parent | dea087689a02c2447723255d13c301031bc2173e (diff) | |
download | rabbitmq-server-f9f26fe6a62e009331574bd60cce22366ce48712.tar.gz |
Refactor and document upgrades_to_apply/2
-rw-r--r-- | src/rabbit_upgrade.erl | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/rabbit_upgrade.erl b/src/rabbit_upgrade.erl index 209e5df8..20ef8766 100644 --- a/src/rabbit_upgrade.erl +++ b/src/rabbit_upgrade.erl @@ -90,15 +90,17 @@ unknown_heads(Heads, G) -> [H || H <- Heads, digraph:vertex(G, H) =:= false]. upgrades_to_apply(Heads, G) -> + %% Take all the vertices which can reach the known heads. That's + %% everything we've already applied. Subtract that from all + %% vertices: that's what we have to apply. Unsorted = sets:to_list( sets:subtract( sets:from_list(digraph:vertices(G)), sets:from_list(digraph_utils:reaching(Heads, G)))), - [begin - {StepName, Step} = digraph:vertex(G, StepName), - Step - end || StepName <- digraph_utils:topsort( - digraph_utils:subgraph(G, Unsorted))]. + %% Form a subgraph from that list and find a topological ordering + %% so we can invoke them in order. + [element(2, digraph:vertex(G, StepName)) + || StepName <- digraph_utils:topsort(digraph_utils:subgraph(G, Unsorted))]. heads(G) -> [V || V <- digraph:vertices(G), digraph:out_degree(G, V) =:= 0]. |