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 import 'dart:async'; | 5 import 'dart:async'; |
6 import "dart:convert"; | 6 import "dart:convert"; |
7 | 7 |
8 import 'package:pub_semver/pub_semver.dart'; | 8 import 'package:pub_semver/pub_semver.dart'; |
9 import 'package:stack_trace/stack_trace.dart'; | 9 import 'package:stack_trace/stack_trace.dart'; |
10 | 10 |
(...skipping 13 matching lines...) Loading... |
24 /// that those dependencies place on each other and the requirements imposed by | 24 /// that those dependencies place on each other and the requirements imposed by |
25 /// [lockFile]. | 25 /// [lockFile]. |
26 /// | 26 /// |
27 /// If [useLatest] is given, then only the latest versions of the referenced | 27 /// If [useLatest] is given, then only the latest versions of the referenced |
28 /// packages will be used. This is for forcing an upgrade to one or more | 28 /// packages will be used. This is for forcing an upgrade to one or more |
29 /// packages. | 29 /// packages. |
30 /// | 30 /// |
31 /// If [upgradeAll] is true, the contents of [lockFile] are ignored. | 31 /// If [upgradeAll] is true, the contents of [lockFile] are ignored. |
32 Future<SolveResult> resolveVersions(SolveType type, SystemCache cache, | 32 Future<SolveResult> resolveVersions(SolveType type, SystemCache cache, |
33 Package root, {LockFile lockFile, List<String> useLatest}) { | 33 Package root, {LockFile lockFile, List<String> useLatest}) { |
34 if (lockFile == null) lockFile = new LockFile.empty(cache.sources); | 34 if (lockFile == null) lockFile = new LockFile.empty(); |
35 if (useLatest == null) useLatest = []; | 35 if (useLatest == null) useLatest = []; |
36 | 36 |
37 return log.progress('Resolving dependencies', () { | 37 return log.progress('Resolving dependencies', () { |
38 return new BacktrackingSolver(type, cache, root, lockFile, useLatest) | 38 return new BacktrackingSolver(type, cache, root, lockFile, useLatest) |
39 .solve(); | 39 .solve(); |
40 }); | 40 }); |
41 } | 41 } |
42 | 42 |
43 /// The result of a version resolution. | 43 /// The result of a version resolution. |
44 class SolveResult { | 44 class SolveResult { |
(...skipping 31 matching lines...) Loading... |
76 | 76 |
77 /// The [LockFile] representing the packages selected by this version | 77 /// The [LockFile] representing the packages selected by this version |
78 /// resolution. | 78 /// resolution. |
79 LockFile get lockFile { | 79 LockFile get lockFile { |
80 // Don't factor in overridden dependencies' SDK constraints, because we'll | 80 // Don't factor in overridden dependencies' SDK constraints, because we'll |
81 // accept those packages even if their constraints don't match. | 81 // accept those packages even if their constraints don't match. |
82 var sdkConstraint = new VersionConstraint.intersection(pubspecs.values | 82 var sdkConstraint = new VersionConstraint.intersection(pubspecs.values |
83 .where((pubspec) => | 83 .where((pubspec) => |
84 !_root.dependencyOverrides.any((dep) => dep.name == pubspec.name)) | 84 !_root.dependencyOverrides.any((dep) => dep.name == pubspec.name)) |
85 .map((pubspec) => pubspec.environment.sdkVersion)); | 85 .map((pubspec) => pubspec.environment.sdkVersion)); |
86 return new LockFile(packages, _sources, sdkConstraint: sdkConstraint); | 86 return new LockFile(packages, sdkConstraint: sdkConstraint); |
87 } | 87 } |
88 | 88 |
89 final SourceRegistry _sources; | 89 final SourceRegistry _sources; |
90 final Package _root; | 90 final Package _root; |
91 final LockFile _previousLockFile; | 91 final LockFile _previousLockFile; |
92 | 92 |
93 /// Returns the names of all packages that were changed. | 93 /// Returns the names of all packages that were changed. |
94 /// | 94 /// |
95 /// This includes packages that were added or removed. | 95 /// This includes packages that were added or removed. |
96 Set<String> get changedPackages { | 96 Set<String> get changedPackages { |
97 if (packages == null) return null; | 97 if (packages == null) return null; |
98 | 98 |
99 var changed = packages | 99 var changed = packages |
100 .where((id) => | 100 .where((id) => _previousLockFile.packages[id.name] != id) |
101 !_sources.idsEqual(_previousLockFile.packages[id.name], id)) | |
102 .map((id) => id.name).toSet(); | 101 .map((id) => id.name).toSet(); |
103 | 102 |
104 return changed.union(_previousLockFile.packages.keys | 103 return changed.union(_previousLockFile.packages.keys |
105 .where((package) => !availableVersions.containsKey(package)) | 104 .where((package) => !availableVersions.containsKey(package)) |
106 .toSet()); | 105 .toSet()); |
107 } | 106 } |
108 | 107 |
109 SolveResult.success(this._sources, this._root, this._previousLockFile, | 108 SolveResult.success(this._sources, this._root, this._previousLockFile, |
110 this.packages, this.overrides, this.pubspecs, this.availableVersions, | 109 this.packages, this.overrides, this.pubspecs, this.availableVersions, |
111 this.attemptedSolutions) | 110 this.attemptedSolutions) |
(...skipping 325 matching lines...) Loading... |
437 | 436 |
438 DependencyNotFoundException(String package, this._innerException, | 437 DependencyNotFoundException(String package, this._innerException, |
439 Iterable<Dependency> dependencies) | 438 Iterable<Dependency> dependencies) |
440 : super(package, dependencies); | 439 : super(package, dependencies); |
441 | 440 |
442 /// The failure isn't because of the version of description of the package, | 441 /// The failure isn't because of the version of description of the package, |
443 /// it's the package itself that can't be found, so just show the name and no | 442 /// it's the package itself that can't be found, so just show the name and no |
444 /// descriptive details. | 443 /// descriptive details. |
445 String _describeDependency(PackageDep dep) => ""; | 444 String _describeDependency(PackageDep dep) => ""; |
446 } | 445 } |
OLD | NEW |