Skip to content

Commit

Permalink
Merge 'RichardLake/RelResVersionFix2' (#1219)
Browse files Browse the repository at this point in the history
* RichardLake/RelResVersionFix2:
  Fix for uncaught Inconsistent Kraken.
  • Loading branch information
pjf committed Jun 30, 2015
2 parents e8eeb1a + 5648de3 commit b447380
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions Core/Relationships/RelationshipResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ public class RelationshipResolver
private static readonly ILog log = LogManager.GetLogger(typeof (RelationshipResolver));
private readonly Dictionary<string, CkanModule> modlist = new Dictionary<string, CkanModule>();
private readonly List<CkanModule> user_requested_mods = new List<CkanModule>();

//TODO As the conflict detection gets more advanced there is a greater need to have messages in here
// as recreating them from reasons is no longer possible.
private readonly List<KeyValuePair<Module, Module>> conflicts =
new List<KeyValuePair<Module, Module>>();
private readonly Dictionary<Module, SelectionReason> reasons =
Expand Down Expand Up @@ -155,9 +158,7 @@ public static RelationshipResolverOptions DefaultOpts()
}

/// <summary>
/// Add modules to consideration of the relationship resolver. Optional installed parameter defaults
/// to installed mods and is intended to be used when this is incorrect, such as when some are to be
/// removed.
/// Add modules to consideration of the relationship resolver.
/// </summary>
/// <param name="modules">Modules to attempt to install</param>
public void AddModulesToInstall(IEnumerable<CkanModule> modules)
Expand Down Expand Up @@ -290,21 +291,35 @@ private void ResolveStanza(IEnumerable<RelationshipDescriptor> stanza, Selection

if (modlist.ContainsKey(dep_name))
{
if (descriptor.version_within_bounds(modlist[dep_name].version))
var module = modlist[dep_name];
if (descriptor.version_within_bounds(module.version))
continue;
//TODO Ideally we could check here if it can be replaced by the version we want.
if (options.procede_with_inconsistencies)
{
conflicts.Add(new KeyValuePair<Module, Module>(module,reason.Parent));
conflicts.Add(new KeyValuePair<Module, Module>(reason.Parent,module));
continue;
}
throw new InconsistentKraken(
string.Format(
"{0} requires a version {1}. However a incompatible version, {2}, is in the resolver",
dep_name, descriptor.RequiredVersion, modlist[dep_name].version));

dep_name, descriptor.RequiredVersion, module.version));
}

if (registry.IsInstalled(dep_name))
{
if(descriptor.version_within_bounds(registry.InstalledVersion(dep_name)))
continue;
continue;
var module = registry.InstalledModule(dep_name).Module;

//TODO Ideally we could check here if it can be replaced by the version we want.
if (options.procede_with_inconsistencies)
{
conflicts.Add(new KeyValuePair<Module, Module>(module, reason.Parent));
conflicts.Add(new KeyValuePair<Module, Module>(reason.Parent, module));
continue;
}
throw new InconsistentKraken(
string.Format(
"{0} requires a version {1}. However a incompatible version, {2}, is already installed",
Expand Down

0 comments on commit b447380

Please sign in to comment.