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

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

Issue 242373006: Show a better error message on no version errors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 186ac8e7cb88fed86462366dfd8d9ef48127e403..5411a9c2affe9eb4e57e3af923e72a4086cb4642 100644
--- a/sdk/lib/_internal/pub/lib/src/solver/backtracking_solver.dart
+++ b/sdk/lib/_internal/pub/lib/src/solver/backtracking_solver.dart
@@ -144,15 +144,9 @@ class BacktrackingSolver {
// Gather some solving metrics.
var buffer = new StringBuffer();
buffer.writeln('${runtimeType} took ${stopwatch.elapsed} seconds.');
- buffer.writeln(
- '- Requested ${cache.versionCacheMisses} version lists');
- buffer.writeln(
- '- Looked up ${cache.versionCacheHits} cached version lists');
- buffer.writeln(
- '- Requested ${cache.pubspecCacheMisses} pubspecs');
- buffer.writeln(
- '- Looked up ${cache.pubspecCacheHits} cached pubspecs');
+ cache.writeResults(buffer);
nweiz 2014/04/21 21:38:49 I really hate passing around string buffers. Just
Bob Nystrom 2014/04/21 22:58:32 I actually like passing around the buffer because
log.solver(buffer);
+
});
}
@@ -491,11 +485,11 @@ class Traverser {
for (var dep in deps) {
if (!dep.isRoot && !_solver.sources.contains(dep.source)) {
throw new UnknownSourceException(id.name,
- [new Dependency(id.name, dep)]);
+ [new Dependency(id.name, id.version, dep)]);
}
}
- return _traverseDeps(id.name, new DependencyQueue(_solver, deps));
+ return _traverseDeps(id, new DependencyQueue(_solver, deps));
});
}
@@ -504,7 +498,8 @@ class Traverser {
/// Desctructively modifies [deps]. Completes to a list of packages if the
/// traversal is complete. Completes it to an error if a failure occurred.
/// Otherwise, recurses.
- Future<List<PackageId>> _traverseDeps(String depender, DependencyQueue deps) {
+ Future<List<PackageId>> _traverseDeps(PackageId depender,
+ DependencyQueue deps) {
// Move onto the next package if we've traversed all of these references.
if (deps.isEmpty) return _traversePackage();
@@ -514,7 +509,7 @@ class Traverser {
// Add the dependency.
var dependencies = _getDependencies(dep.name);
- dependencies.add(new Dependency(depender, dep));
+ dependencies.add(new Dependency(depender.name, depender.version, dep));
// If the package is barback, pub has an implicit version constraint on
// it since pub itself uses barback too. Note that we don't check for
@@ -534,7 +529,7 @@ class Traverser {
// find barback.
var barbackDep = new PackageDep(dep.name, dep.source,
barback.supportedVersions, dep.description);
- dependencies.add(new Dependency("pub itself", barbackDep));
+ dependencies.add(new Dependency("pub itself", null, barbackDep));
}
var constraint = _getConstraint(dep.name);
@@ -578,7 +573,7 @@ class Traverser {
if (allowed.isEmpty) {
_solver.logSolve('no versions for ${dep.name} match $constraint');
- throw new NoVersionException(dep.name, constraint,
+ throw new NoVersionException(dep.name, null, constraint,
_getDependencies(dep.name));
}
@@ -608,7 +603,7 @@ class Traverser {
/// other dependencies on the same package. Throws a [SolveFailure]
/// exception if not. Only validates sources and descriptions, not the
/// version.
- void _validateDependency(PackageDep dep, String depender) {
+ void _validateDependency(PackageDep dep, PackageId depender) {
// Make sure the dependencies agree on source and description.
var required = _getRequired(dep.name);
if (required == null) return;
@@ -618,7 +613,7 @@ class Traverser {
_solver.logSolve('source mismatch on ${dep.name}: ${required.dep.source} '
'!= ${dep.source}');
throw new SourceMismatchException(dep.name,
- [required, new Dependency(depender, dep)]);
+ [required, new Dependency(depender.name, depender.version, dep)]);
}
// Make sure all of the existing descriptions match the new reference.
@@ -627,7 +622,7 @@ class Traverser {
_solver.logSolve('description mismatch on ${dep.name}: '
'${required.dep.description} != ${dep.description}');
throw new DescriptionMismatchException(dep.name,
- [required, new Dependency(depender, dep)]);
+ [required, new Dependency(depender.name, depender.version, dep)]);
}
}
@@ -643,7 +638,7 @@ class Traverser {
// Make sure it meets the constraint.
if (!dep.constraint.allows(selected.version)) {
_solver.logSolve('selection $selected does not match $constraint');
- throw new NoVersionException(dep.name, constraint,
+ throw new NoVersionException(dep.name, selected.version, constraint,
_getDependencies(dep.name));
}

Powered by Google App Engine
This is Rietveld 408576698