| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library version_solver; | 5 library version_solver; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:json' as json; | 8 import 'dart:json' as json; |
| 9 | 9 |
| 10 import '../lock_file.dart'; | 10 import '../lock_file.dart'; |
| 11 import '../log.dart' as log; | 11 import '../log.dart' as log; |
| 12 import '../package.dart'; | 12 import '../package.dart'; |
| 13 import '../pubspec.dart'; | 13 import '../pubspec.dart'; |
| 14 import '../source.dart'; | 14 import '../source.dart'; |
| 15 import '../source_registry.dart'; | 15 import '../source_registry.dart'; |
| 16 import '../version.dart'; | 16 import '../version.dart'; |
| 17 import '../utils.dart'; | 17 import '../utils.dart'; |
| 18 import 'backtracking_solver.dart'; | 18 import 'backtracking_solver.dart'; |
| 19 | 19 |
| 20 /// Attempts to select the best concrete versions for all of the transitive | 20 /// Attempts to select the best concrete versions for all of the transitive |
| 21 /// dependencies of [root] taking into account all of the [VersionConstraint]s | 21 /// dependencies of [root] taking into account all of the [VersionConstraint]s |
| 22 /// that those dependencies place on each other and the requirements imposed by | 22 /// that those dependencies place on each other and the requirements imposed by |
| 23 /// [lockFile]. | 23 /// [lockFile]. |
| 24 /// | 24 /// |
| 25 /// If [useLatest] is given, then only the latest versions of the referenced | 25 /// If [useLatest] is given, then only the latest versions of the referenced |
| 26 /// packages will be used. This is for forcing an update to one or more | 26 /// packages will be used. This is for forcing an update to one or more |
| 27 /// packages. | 27 /// packages. |
| 28 Future<SolveResult> resolveVersions(SourceRegistry sources, Package root, | 28 Future<SolveResult> resolveVersions(SourceRegistry sources, Package root, |
| 29 {LockFile lockFile, List<String> useLatest}) { | 29 {LockFile lockFile, List<String> useLatest}) { |
| 30 log.message('Resolving dependencies...'); | |
| 31 | |
| 32 if (lockFile == null) lockFile = new LockFile.empty(); | 30 if (lockFile == null) lockFile = new LockFile.empty(); |
| 33 if (useLatest == null) useLatest = []; | 31 if (useLatest == null) useLatest = []; |
| 34 | 32 |
| 35 return new BacktrackingSolver(sources, root, lockFile, useLatest).solve(); | 33 return log.progress('Resolving dependencies', () { |
| 34 return new BacktrackingSolver(sources, root, lockFile, useLatest).solve(); |
| 35 }); |
| 36 } | 36 } |
| 37 | 37 |
| 38 /// The result of a version resolution. | 38 /// The result of a version resolution. |
| 39 class SolveResult { | 39 class SolveResult { |
| 40 /// Whether the solver found a complete solution or failed. | 40 /// Whether the solver found a complete solution or failed. |
| 41 bool get succeeded => error == null; | 41 bool get succeeded => error == null; |
| 42 | 42 |
| 43 /// The list of concrete package versions that were selected for each package | 43 /// The list of concrete package versions that were selected for each package |
| 44 /// reachable from the root, or `null` if the solver failed. | 44 /// reachable from the root, or `null` if the solver failed. |
| 45 final List<PackageId> packages; | 45 final List<PackageId> packages; |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 Iterable<Dependency> dependencies) | 287 Iterable<Dependency> dependencies) |
| 288 : super(package, dependencies); | 288 : super(package, dependencies); |
| 289 | 289 |
| 290 String get _message => "Incompatible dependencies on '$package'"; | 290 String get _message => "Incompatible dependencies on '$package'"; |
| 291 | 291 |
| 292 String _describeDependency(PackageDep dep) { | 292 String _describeDependency(PackageDep dep) { |
| 293 // TODO(nweiz): Dump descriptions to YAML when that's supported. | 293 // TODO(nweiz): Dump descriptions to YAML when that's supported. |
| 294 return "depends on it with description ${json.stringify(dep.description)}"; | 294 return "depends on it with description ${json.stringify(dep.description)}"; |
| 295 } | 295 } |
| 296 } | 296 } |
| OLD | NEW |