| 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 /** | 5 /** |
| 6 * Attempts to resolve a set of version constraints for a package dependency | 6 * Attempts to resolve a set of version constraints for a package dependency |
| 7 * graph and select an appropriate set of best specific versions for all | 7 * graph and select an appropriate set of best specific versions for all |
| 8 * dependent packages. It works iteratively and tries to reach a stable | 8 * dependent packages. It works iteratively and tries to reach a stable |
| 9 * solution where the constraints of all dependencies are met. If it fails to | 9 * solution where the constraints of all dependencies are met. If it fails to |
| 10 * reach a solution after a certain number of iterations, it assumes the | 10 * reach a solution after a certain number of iterations, it assumes the |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 seen.add(dependency.name); | 190 seen.add(dependency.name); |
| 191 | 191 |
| 192 for (var dependerName in dependency.dependers) { | 192 for (var dependerName in dependency.dependers) { |
| 193 var depender = getDependency(dependerName); | 193 var depender = getDependency(dependerName); |
| 194 var locked = lockFile.packages[dependerName]; | 194 var locked = lockFile.packages[dependerName]; |
| 195 if (locked != null && depender.version == locked.version) { | 195 if (locked != null && depender.version == locked.version) { |
| 196 enqueue(new UnlockPackage(depender)); | 196 enqueue(new UnlockPackage(depender)); |
| 197 return true; | 197 return true; |
| 198 } | 198 } |
| 199 } | 199 } |
| 200 | 200 |
| 201 return dependency.dependers.map(getDependency).some((subdependency) => | 201 return dependency.dependers.map(getDependency).some((subdependency) => |
| 202 tryUnlockDepender(subdependency, seen)); | 202 tryUnlockDepender(subdependency, seen)); |
| 203 } | 203 } |
| 204 | 204 |
| 205 List<PackageId> buildResults() { | 205 List<PackageId> buildResults() { |
| 206 return _packages.getValues().filter((dep) => dep.isDependedOn).map((dep) { | 206 return _packages.getValues().filter((dep) => dep.isDependedOn).map((dep) { |
| 207 var description = dep.description; | 207 var description = dep.description; |
| 208 | 208 |
| 209 // If the lockfile contains a fully-resolved description for the package, | 209 // If the lockfile contains a fully-resolved description for the package, |
| 210 // use that. This allows e.g. Git to ensure that the same commit is used. | 210 // use that. This allows e.g. Git to ensure that the same commit is used. |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 } | 321 } |
| 322 | 322 |
| 323 /** | 323 /** |
| 324 * A constraint that a depending package places on a dependent package has | 324 * A constraint that a depending package places on a dependent package has |
| 325 * changed. | 325 * changed. |
| 326 * | 326 * |
| 327 * This is an abstract class that contains logic for updating the dependency | 327 * This is an abstract class that contains logic for updating the dependency |
| 328 * graph once a dependency has changed. Changing the dependency is the | 328 * graph once a dependency has changed. Changing the dependency is the |
| 329 * responsibility of subclasses. | 329 * responsibility of subclasses. |
| 330 */ | 330 */ |
| 331 class ChangeConstraint implements WorkItem { | 331 abstract class ChangeConstraint implements WorkItem { |
| 332 abstract Future process(VersionSolver solver); | 332 abstract Future process(VersionSolver solver); |
| 333 | 333 |
| 334 abstract void undo(VersionSolver solver); | 334 abstract void undo(VersionSolver solver); |
| 335 | 335 |
| 336 Future _processChange(VersionSolver solver, Dependency oldDependency, | 336 Future _processChange(VersionSolver solver, Dependency oldDependency, |
| 337 Dependency newDependency) { | 337 Dependency newDependency) { |
| 338 var name = newDependency.name; | 338 var name = newDependency.name; |
| 339 var source = oldDependency.source != null ? | 339 var source = oldDependency.source != null ? |
| 340 oldDependency.source : newDependency.source; | 340 oldDependency.source : newDependency.source; |
| 341 var description = oldDependency.description != null ? | 341 var description = oldDependency.description != null ? |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 final description1; | 723 final description1; |
| 724 final description2; | 724 final description2; |
| 725 | 725 |
| 726 DescriptionMismatchException(this.package, this.description1, | 726 DescriptionMismatchException(this.package, this.description1, |
| 727 this.description2); | 727 this.description2); |
| 728 | 728 |
| 729 // TODO(nweiz): Dump to YAML when that's supported | 729 // TODO(nweiz): Dump to YAML when that's supported |
| 730 String toString() => "Package '$package' has conflicting descriptions " | 730 String toString() => "Package '$package' has conflicting descriptions " |
| 731 "'${JSON.stringify(description1)}' and '${JSON.stringify(description2)}'"; | 731 "'${JSON.stringify(description1)}' and '${JSON.stringify(description2)}'"; |
| 732 } | 732 } |
| OLD | NEW |