Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(606)

Unified Diff: sdk/lib/_internal/pub/lib/src/solver/backtracking_solver.dart

Issue 15347004: Gracefully handle pubspecs with dependencies using unknown sources. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Handle bad sources in dev deps. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/pub/lib/src/solver/backtracking_solver.dart
diff --git a/sdk/lib/_internal/pub/lib/src/solver/backtracking_solver.dart b/sdk/lib/_internal/pub/lib/src/solver/backtracking_solver.dart
index 97d35dad9e930cd0bc787dbe2762d4de414e7653..e2fdc48afec00ebb0f82addeeabbe3e35117e9a1 100644
--- a/sdk/lib/_internal/pub/lib/src/solver/backtracking_solver.dart
+++ b/sdk/lib/_internal/pub/lib/src/solver/backtracking_solver.dart
@@ -387,6 +387,14 @@ class Traverser {
// Include dev dependencies of the root package.
if (id.isRoot) deps.addAll(pubspec.devDependencies);
+ // Make sure the package doesn't have any bad dependencies.
+ for (var dep in deps) {
+ if (!dep.isRoot && !_solver.sources.contains(dep.source)) {
+ throw new UnknownSourceException(id.name,
+ [new Dependency(id.name, dep)]);
+ }
+ }
+
// Given a package dep, returns a future that completes to a pair of the
// dep and the number of versions available for it.
getNumVersions(PackageDep dep) {
@@ -395,7 +403,7 @@ class Traverser {
return new Future.value(new Pair<PackageDep, int>(dep, 1));
}
- return _solver.cache.getVersions(dep.toRef()).then((versions) {
+ return _solver.cache.getVersions(dep).then((versions) {
return new Pair<PackageDep, int>(dep, versions.length);
}).catchError((error) {
// If it fails for any reason, just treat that as no versions. This
@@ -474,7 +482,7 @@ class Traverser {
if (required == null) return;
// Make sure all of the existing sources match the new reference.
- if (required.dep.source.name != dep.source.name) {
+ if (required.dep.source != dep.source) {
_solver.logSolve('source mismatch on ${dep.name}: ${required.dep.source} '
'!= ${dep.source}');
throw new SourceMismatchException(dep.name,
@@ -482,7 +490,8 @@ class Traverser {
}
// Make sure all of the existing descriptions match the new reference.
- if (!dep.descriptionEquals(required.dep)) {
+ var source = _solver.sources[dep.source];
+ if (!source.descriptionsEqual(dep.description, required.dep.description)) {
_solver.logSolve('description mismatch on ${dep.name}: '
'${required.dep.description} != ${dep.description}');
throw new DescriptionMismatchException(dep.name,
@@ -542,7 +551,7 @@ class Traverser {
/// could not be selected or that completes successfully if a package was
/// selected and traversing should continue.
Future _selectPackage(PackageDep dep, VersionConstraint constraint) {
- return _solver.cache.getVersions(dep.toRef()).then((versions) {
+ return _solver.cache.getVersions(dep).then((versions) {
var allowed = versions.where((id) => constraint.allows(id.version));
// See if it's in the lockfile. If so, try that version first. If the
@@ -608,8 +617,11 @@ class Traverser {
var required = _getRequired(name);
if (required != null) {
- if (package.source.name != required.dep.source.name) return null;
- if (!package.descriptionEquals(required.dep)) return null;
+ if (package.source != required.dep.source) return null;
+
+ var source = _solver.sources[package.source];
+ if (!source.descriptionsEqual(
+ package.description, required.dep.description)) return null;
}
return package;

Powered by Google App Engine
This is Rietveld 408576698