Chromium Code Reviews| Index: sdk/lib/_internal/pub/lib/src/solver/version_solver.dart |
| diff --git a/sdk/lib/_internal/pub/lib/src/solver/version_solver.dart b/sdk/lib/_internal/pub/lib/src/solver/version_solver.dart |
| index 54c5ab466e15115b8ff41bf67a3ba6fce216eabf..dc623d6672c9efd4529c722ab95613d3f8db0081 100644 |
| --- a/sdk/lib/_internal/pub/lib/src/solver/version_solver.dart |
| +++ b/sdk/lib/_internal/pub/lib/src/solver/version_solver.dart |
| @@ -15,6 +15,7 @@ import '../source_registry.dart'; |
| import '../version.dart'; |
| import '../utils.dart'; |
| import 'backtracking_solver.dart'; |
| +import 'solve_report.dart'; |
| /// Attempts to select the best concrete versions for all of the transitive |
| /// dependencies of [root] taking into account all of the [VersionConstraint]s |
| @@ -24,13 +25,16 @@ import 'backtracking_solver.dart'; |
| /// If [useLatest] is given, then only the latest versions of the referenced |
| /// packages will be used. This is for forcing an upgrade to one or more |
| /// packages. |
| +/// |
| +/// If [upgradeAll] is true, the contents of [lockFile] are ignored. |
| Future<SolveResult> resolveVersions(SourceRegistry sources, Package root, |
| - {LockFile lockFile, List<String> useLatest}) { |
| + {LockFile lockFile, List<String> useLatest, bool upgradeAll}) { |
| if (lockFile == null) lockFile = new LockFile.empty(); |
| if (useLatest == null) useLatest = []; |
| return log.progress('Resolving dependencies', () { |
| - return new BacktrackingSolver(sources, root, lockFile, useLatest).solve(); |
| + return new BacktrackingSolver(sources, root, lockFile, useLatest, |
| + upgradeAll: upgradeAll).solve(); |
| }); |
| } |
| @@ -46,6 +50,13 @@ class SolveResult { |
| /// The dependency overrides that were used in the solution. |
| final List<PackageDep> overrides; |
| + /// The available versions of all selected packages from their source. |
| + /// |
| + /// Will be empty if the solve failed. An entry here may not include the full |
| + /// list of versions available if the given package was locked and did not |
| + /// need to be unlocked during the solve. |
| + final Map<String, List<Version>> availableVersions; |
| + |
| /// The error that prevented the solver from finding a solution or `null` if |
| /// it was successful. |
| final SolveFailure error; |
| @@ -56,9 +67,25 @@ class SolveResult { |
| /// solution. |
| final int attemptedSolutions; |
| - SolveResult(this.packages, this.overrides, this.error, |
| + final SourceRegistry _sources; |
| + final Package _root; |
| + final LockFile _previousLockFile; |
| + |
| + SolveResult(this._sources, this._root, this._previousLockFile, this.packages, |
| + this.overrides, this.availableVersions, this.error, |
| this.attemptedSolutions); |
| + /// Displays a report of what changes were made to the lockfile. |
| + /// |
| + /// If [showAll] is true, displays all new and previous dependencies. |
| + /// Otherwise, just shows a warning for any overrides in effect. |
| + /// |
| + /// Returns the number of changed (added, removed, or modified) dependencies. |
| + int showReport({bool showAll}) { |
| + var report = new SolveReport(_sources, _root, _previousLockFile, this); |
| + return report.show(showAll: showAll); |
| + } |
| + |
| String toString() { |
| if (!succeeded) { |
| return 'Failed to solve after $attemptedSolutions attempts:\n' |
| @@ -163,6 +190,11 @@ class PubspecCache { |
| return ids; |
| }); |
| } |
| + |
| + /// Returns the previously cached list of versions for the package identified |
| + /// by [package] |
|
nweiz
2013/12/11 06:48:32
Extra newline
Bob Nystrom
2013/12/11 22:36:59
Done.
|
| + /// or returns `null` if not in the cache. |
| + List<PackageId> getCachedVersions(PackageRef package) => _versions[package]; |
| } |
| /// A reference from a depending package to a package that it depends on. |