86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/solve/solver.rb', line 86
def resolve
seed_demand_dependencies
while unbound_variable = variable_table.first_unbound
possible_values_for_unbound = possible_values_for(unbound_variable)
while possible_value = possible_values_for_unbound.shift
possible_artifact = graph.get_artifact(unbound_variable.package, possible_value.version)
possible_dependencies = possible_artifact.dependencies
all_ok = possible_dependencies.all? { |dependency| can_add_new_constraint?(dependency) }
if all_ok
add_dependencies(possible_dependencies, possible_artifact)
unbound_variable.bind(possible_value)
break
end
end
unless unbound_variable.bound?
backtrack(unbound_variable)
end
end
{}.tap do |solution|
variable_table.rows.each do |variable|
solution[variable.package] = variable.value.version.to_s
end
end
end
|