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 'backtracking_solver.dart'; | 17 import 'backtracking_solver.dart'; |
18 import 'greedy_solver.dart'; | 18 import 'greedy_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 /// | 28 /// |
29 /// If [allowBacktracking] is `false` the non-backtracking version solver will | 29 /// If [allowBacktracking] is `true` the backtracking version solver will |
30 /// be used. Otherwise, the backtracking one will be. | 30 /// be used. Otherwise, the non-backtracking one will be. |
31 Future<SolveResult> resolveVersions(SourceRegistry sources, Package root, | 31 Future<SolveResult> resolveVersions(SourceRegistry sources, Package root, |
32 {LockFile lockFile, bool allowBacktracking, List<PackageRef> useLatest}) { | 32 {LockFile lockFile, bool allowBacktracking, List<PackageRef> useLatest}) { |
33 log.message('Resolving dependencies...'); | 33 log.message('Resolving dependencies...'); |
34 | 34 |
35 if (allowBacktracking == null) allowBacktracking = true; | 35 if (allowBacktracking == null) allowBacktracking = false; |
36 if (lockFile == null) lockFile = new LockFile.empty(); | 36 if (lockFile == null) lockFile = new LockFile.empty(); |
37 if (useLatest == null) useLatest = []; | 37 if (useLatest == null) useLatest = []; |
38 | 38 |
39 var solver; | 39 var solver; |
40 if (allowBacktracking) { | 40 if (allowBacktracking) { |
41 solver = new BacktrackingVersionSolver(sources, root, lockFile, useLatest); | 41 solver = new BacktrackingVersionSolver(sources, root, lockFile, useLatest); |
42 } else { | 42 } else { |
43 solver = new GreedyVersionSolver(sources, root, lockFile, useLatest); | 43 solver = new GreedyVersionSolver(sources, root, lockFile, useLatest); |
44 } | 44 } |
45 | 45 |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 Iterable<Dependency> dependencies) | 370 Iterable<Dependency> dependencies) |
371 : super(package, dependencies); | 371 : super(package, dependencies); |
372 | 372 |
373 String get _message => "Incompatible dependencies on '$package'"; | 373 String get _message => "Incompatible dependencies on '$package'"; |
374 | 374 |
375 String _describeDependency(PackageRef ref) { | 375 String _describeDependency(PackageRef ref) { |
376 // TODO(nweiz): Dump descriptions to YAML when that's supported. | 376 // TODO(nweiz): Dump descriptions to YAML when that's supported. |
377 return "depends on it with description ${json.stringify(ref.description)}"; | 377 return "depends on it with description ${json.stringify(ref.description)}"; |
378 } | 378 } |
379 } | 379 } |
OLD | NEW |