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

Unified Diff: lib/src/command/deps.dart

Issue 1307853004: Improve the heuristics for "pub get" is needed. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Code review changes Created 5 years, 4 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
« no previous file with comments | « no previous file | lib/src/entrypoint.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/command/deps.dart
diff --git a/lib/src/command/deps.dart b/lib/src/command/deps.dart
index 25bfa910fd2c897d4b2698c2dda3b7184b084cc3..32cb0cdd447f5e265171bebc4e9c7c83e9f8aa7d 100644
--- a/lib/src/command/deps.dart
+++ b/lib/src/command/deps.dart
@@ -74,7 +74,7 @@ class DepsCommand extends PubCommand {
_buffer.writeln();
_buffer.writeln("$section:");
for (var name in ordered(names)) {
- var package = entrypoint.packageGraph.packages[name];
+ var package = _getPackage(name);
_buffer.write("- ${_labelPackage(package)}");
if (package.dependencies.isEmpty) {
@@ -115,7 +115,7 @@ class DepsCommand extends PubCommand {
_buffer.writeln("$name:");
for (var name in deps) {
- var package = entrypoint.packageGraph.packages[name];
+ var package = _getPackage(name);
_buffer.writeln("- ${_labelPackage(package)}");
for (var dep in package.dependencies) {
@@ -141,8 +141,7 @@ class DepsCommand extends PubCommand {
// Start with the root dependencies.
var packageTree = {};
for (var dep in entrypoint.root.immediateDependencies) {
- toWalk.add(
- new Pair(entrypoint.packageGraph.packages[dep.name], packageTree));
+ toWalk.add(new Pair(_getPackage(dep.name), packageTree));
}
// Do a breadth-first walk to the dependency graph.
@@ -163,8 +162,7 @@ class DepsCommand extends PubCommand {
map[_labelPackage(package)] = childMap;
for (var dep in package.dependencies) {
- toWalk.add(
- new Pair(entrypoint.packageGraph.packages[dep.name], childMap));
+ toWalk.add(new Pair(_getPackage(dep.name), childMap));
}
}
@@ -184,4 +182,17 @@ class DepsCommand extends PubCommand {
transitive.removeAll(root.dependencyOverrides.map((dep) => dep.name));
return transitive;
}
+
+ /// Get the package named [name], or throw a [DataError] if it's not
+ /// available.
+ ///
+ /// It's very unlikely that the lockfile won't be up-to-date with the pubspec,
+ /// but it's possible, since [Entrypoint.assertUpToDate]'s modification time
+ /// check can return a false negative. This fails gracefully if that happens.
+ Package _getPackage(String name) {
+ var package = entrypoint.packageGraph.packages[name];
+ if (package != null) return package;
+ dataError('The pubspec.yaml file has changed since the pubspec.lock file '
+ 'was generated, please run "pub get" again.');
+ }
}
« no previous file with comments | « no previous file | lib/src/entrypoint.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698