Skip to content

Commit

Permalink
Extract getCurrentRequirement
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Jan 15, 2016
1 parent 39338bb commit 72a30b6
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/Paket.Core/PackageResolver.fs
Original file line number Diff line number Diff line change
Expand Up @@ -378,23 +378,25 @@ let Resolve(groupName:GroupName, sources, getVersionsF, getPackageDetailsF, stra
| _ -> Set.empty)
|> Set.unionMany

let getCurrentRequirement (openRequirements:Set<PackageRequirement>) =
let currentMin = ref (Seq.head openRequirements)
let currentBoost = ref 0
for d in openRequirements do
let boost =
match conflictHistory.TryGetValue d.Name with
| true,c -> -c
| _ -> 0
if PackageRequirement.Compare(d,!currentMin,packageFilter,boost,!currentBoost) = -1 then
currentMin := d
currentBoost := boost
!currentMin


let rec step (relax,filteredVersions:Map<PackageName, ((SemVerInfo * PackageSource list) list * bool)>,currentResolution:Map<PackageName,ResolvedPackage>,closedRequirements:Set<PackageRequirement>,openRequirements:Set<PackageRequirement>) =
if Set.isEmpty openRequirements then Resolution.Ok(cleanupNames currentResolution) else
verbosefn " %d packages in resolution. %d requirements left" currentResolution.Count openRequirements.Count

let currentRequirement =
let currentMin = ref (Seq.head openRequirements)
let currentBoost = ref 0
for d in openRequirements do
let boost =
match conflictHistory.TryGetValue d.Name with
| true,c -> -c
| _ -> 0
if PackageRequirement.Compare(d,!currentMin,packageFilter,boost,!currentBoost) = -1 then
currentMin := d
currentBoost := boost
!currentMin

let currentRequirement = getCurrentRequirement openRequirements
let conflicts = getConflicts(filteredVersions,closedRequirements,openRequirements,currentRequirement)
if conflicts |> Set.isEmpty |> not then Resolution.Conflict(currentResolution,closedRequirements,conflicts,Seq.head conflicts,getVersionsF sources ResolverStrategy.Max groupName) else

Expand Down

0 comments on commit 72a30b6

Please sign in to comment.