Skip to content

Commit

Permalink
Install settings from paket.dependencies should override package sett…
Browse files Browse the repository at this point in the history
…ings - fixes #688
  • Loading branch information
forki committed Mar 10, 2015
1 parent a22ce1f commit aa811dd
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#### 0.32.1 - 10.03.2015
* BUGFIX: Install settings from `paket.dependencies` should override package settings - https://github.com/fsprojects/Paket/issues/688

#### 0.32.0 - 09.03.2015
* PERFORMANCE: If resolver runs into conflict then use Warnsdorff's rule - https://github.com/fsprojects/Paket/pull/684
* BUGFIX: Fixed Linux install scripts - https://github.com/fsprojects/Paket/pull/681
Expand Down
40 changes: 27 additions & 13 deletions src/Paket.Core/PackageResolver.fs
Original file line number Diff line number Diff line change
Expand Up @@ -151,21 +151,27 @@ let Resolve(getVersionsF, getPackageDetailsF, globalFrameworkRestrictions, rootD
let allVersions = Dictionary<NormalizedPackageName,SemVerInfo list>()
let conflictHistory = Dictionary<NormalizedPackageName,int>()

let getExploredPackage(packageCount,sources,packageName:PackageName,version,settings:InstallSettings) =
let normalizedPackageName = NormalizedPackageName packageName
let (PackageName name) = packageName
let getExploredPackage(dependency:PackageRequirement,version) =
let normalizedPackageName = NormalizedPackageName dependency.Name
let (PackageName name) = dependency.Name
match exploredPackages.TryGetValue <| (normalizedPackageName,version) with
| true,package -> package
| true,package ->
match dependency.Parent with
| PackageRequirementSource.DependenciesFile(_) ->
let package = { package with Settings = { package.Settings with FrameworkRestrictions = dependency.Settings.FrameworkRestrictions } }
exploredPackages.[(normalizedPackageName,version)] <- package
package
| _ -> package
| false,_ ->
tracefn " %d packages found - Adding %s %A" packageCount name version
let packageDetails : PackageDetails = getPackageDetailsF sources packageName version
let restrictedDependencies = DependencySetFilter.filterByRestrictions (settings.FrameworkRestrictions @ globalFrameworkRestrictions) packageDetails.DirectDependencies
tracefn " - %s %A" name version
let packageDetails : PackageDetails = getPackageDetailsF dependency.Sources dependency.Name version
let restrictedDependencies = DependencySetFilter.filterByRestrictions (dependency.Settings.FrameworkRestrictions @ globalFrameworkRestrictions) packageDetails.DirectDependencies
let explored =
{ Name = packageDetails.Name
Version = version
Dependencies = restrictedDependencies
Unlisted = packageDetails.Unlisted
Settings = settings
Settings = dependency.Settings
Source = packageDetails.Source }
exploredPackages.Add((normalizedPackageName,version),explored)
explored
Expand Down Expand Up @@ -200,10 +206,17 @@ let Resolve(getVersionsF, getPackageDetailsF, globalFrameworkRestrictions, rootD
| _ -> false)

if isOk then
ResolvedPackages.Ok(packages |> Seq.fold (fun map p -> Map.add (NormalizedPackageName p.Name) p map) Map.empty)
let resolution =
packages
|> Seq.fold (fun map p -> Map.add (NormalizedPackageName p.Name) p map) Map.empty

ResolvedPackages.Ok(resolution)
else
ResolvedPackages.Conflict(closed,stillOpen)
else
let packageCount = packages |> List.length
verbosefn " %d packages in resolution. %d requirements left" packageCount stillOpen.Count

let dependency =
let currentMin = ref (Seq.head stillOpen)
let currentBoost = ref 0
Expand Down Expand Up @@ -272,16 +285,17 @@ let Resolve(getVersionsF, getPackageDetailsF, globalFrameworkRestrictions, rootD
|> List.fold (fun (allUnlisted,state) versionToExplore ->
match state with
| ResolvedPackages.Conflict _ ->
let packageCount = packages |> List.length
let exploredPackage = getExploredPackage(packageCount,dependency.Sources,dependency.Name,versionToExplore,dependency.Settings)
let exploredPackage = getExploredPackage(dependency,versionToExplore)
if exploredPackage.Unlisted && not useUnlisted then
allUnlisted,state
else
let newFilteredVersions = Map.add dependency.Name ([versionToExplore],!globalOverride) filteredVersions

let newOpen = calcOpenRequirements(exploredPackage,globalFrameworkRestrictions,versionToExplore,dependency,closed,stillOpen)

let improved = improveModel (newFilteredVersions,exploredPackage::packages,Set.add dependency closed,newOpen)
let newPackages =
exploredPackage::(packages |> List.filter (fun p -> NormalizedPackageName p.Name <> NormalizedPackageName exploredPackage.Name || p.Version <> exploredPackage.Version))

let improved = improveModel (newFilteredVersions,newPackages,Set.add dependency closed,newOpen)
(exploredPackage.Unlisted && allUnlisted),improved

| ResolvedPackages.Ok _ -> allUnlisted,state)
Expand Down
2 changes: 1 addition & 1 deletion src/Paket/Paket.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<WarningLevel>3</WarningLevel>
<DocumentationFile>
</DocumentationFile>
<StartArguments>outdated</StartArguments>
<StartArguments>update</StartArguments>
<StartAction>Project</StartAction>
<StartProgram>paket.exe</StartProgram>
<StartWorkingDirectory>c:\code\Paket09x</StartWorkingDirectory>
Expand Down

0 comments on commit aa811dd

Please sign in to comment.