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 pub.solver.version_solver; | 5 library pub.solver.version_solver; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import "dart:convert"; | 8 import "dart:convert"; |
9 | 9 |
| 10 import 'package:pub_semver/pub_semver.dart'; |
10 import 'package:stack_trace/stack_trace.dart'; | 11 import 'package:stack_trace/stack_trace.dart'; |
11 | 12 |
12 import '../exceptions.dart'; | 13 import '../exceptions.dart'; |
13 import '../lock_file.dart'; | 14 import '../lock_file.dart'; |
14 import '../log.dart' as log; | 15 import '../log.dart' as log; |
15 import '../package.dart'; | 16 import '../package.dart'; |
16 import '../pubspec.dart'; | 17 import '../pubspec.dart'; |
17 import '../source_registry.dart'; | 18 import '../source_registry.dart'; |
18 import '../version.dart'; | |
19 import '../utils.dart'; | 19 import '../utils.dart'; |
20 import 'backtracking_solver.dart'; | 20 import 'backtracking_solver.dart'; |
21 import 'solve_report.dart'; | 21 import 'solve_report.dart'; |
22 | 22 |
23 /// Attempts to select the best concrete versions for all of the transitive | 23 /// Attempts to select the best concrete versions for all of the transitive |
24 /// dependencies of [root] taking into account all of the [VersionConstraint]s | 24 /// dependencies of [root] taking into account all of the [VersionConstraint]s |
25 /// that those dependencies place on each other and the requirements imposed by | 25 /// that those dependencies place on each other and the requirements imposed by |
26 /// [lockFile]. | 26 /// [lockFile]. |
27 /// | 27 /// |
28 /// If [useLatest] is given, then only the latest versions of the referenced | 28 /// If [useLatest] is given, then only the latest versions of the referenced |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 _versionCacheHits++; | 219 _versionCacheHits++; |
220 return new Future.error(error.first, error.last); | 220 return new Future.error(error.first, error.last); |
221 } | 221 } |
222 | 222 |
223 _versionCacheMisses++; | 223 _versionCacheMisses++; |
224 | 224 |
225 var source = _sources[package.source]; | 225 var source = _sources[package.source]; |
226 return source.getVersions(package.name, package.description) | 226 return source.getVersions(package.name, package.description) |
227 .then((versions) { | 227 .then((versions) { |
228 // Sort by priority so we try preferred versions first. | 228 // Sort by priority so we try preferred versions first. |
229 versions.sort(_type == SolveType.DOWNGRADE ? Version.antiPrioritize : | 229 versions.sort(_type == SolveType.DOWNGRADE ? Version.antiprioritize : |
230 Version.prioritize); | 230 Version.prioritize); |
231 | 231 |
232 var ids = versions.reversed.map( | 232 var ids = versions.reversed.map( |
233 (version) => package.atVersion(version)).toList(); | 233 (version) => package.atVersion(version)).toList(); |
234 _versions[package] = ids; | 234 _versions[package] = ids; |
235 return ids; | 235 return ids; |
236 }).catchError((error, trace) { | 236 }).catchError((error, trace) { |
237 // If an error occurs, cache that too. We only want to do one request | 237 // If an error occurs, cache that too. We only want to do one request |
238 // for any given package, successful or not. | 238 // for any given package, successful or not. |
239 log.solver("Could not get versions for $package:\n$error\n\n$trace"); | 239 log.solver("Could not get versions for $package:\n$error\n\n$trace"); |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 | 492 |
493 DependencyNotFoundException(String package, this._innerException, | 493 DependencyNotFoundException(String package, this._innerException, |
494 Iterable<Dependency> dependencies) | 494 Iterable<Dependency> dependencies) |
495 : super(package, dependencies); | 495 : super(package, dependencies); |
496 | 496 |
497 /// The failure isn't because of the version of description of the package, | 497 /// The failure isn't because of the version of description of the package, |
498 /// it's the package itself that can't be found, so just show the name and no | 498 /// it's the package itself that can't be found, so just show the name and no |
499 /// descriptive details. | 499 /// descriptive details. |
500 String _describeDependency(PackageDep dep) => ""; | 500 String _describeDependency(PackageDep dep) => ""; |
501 } | 501 } |
OLD | NEW |