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

Unified Diff: lib/src/package_graph.dart

Issue 1282533003: Don't implicitly run "pub get". (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 | « lib/src/global_packages.dart ('k') | lib/src/source/path.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/package_graph.dart
diff --git a/lib/src/package_graph.dart b/lib/src/package_graph.dart
index b2a3a54f83da2c3eae4a7028f6f606b729442e9f..c500b80adcfd8bf33d2376c448e23571cec406e5 100644
--- a/lib/src/package_graph.dart
+++ b/lib/src/package_graph.dart
@@ -8,12 +8,11 @@ import 'barback/transformer_cache.dart';
import 'entrypoint.dart';
import 'lock_file.dart';
import 'package.dart';
+import 'solver/version_solver.dart';
import 'source/cached.dart';
import 'utils.dart';
/// A holistic view of the entire transitive dependency graph for an entrypoint.
-///
-/// A package graph can be loaded using [Entrypoint.loadPackageGraph].
class PackageGraph {
/// The entrypoint.
final Entrypoint entrypoint;
@@ -39,6 +38,27 @@ class PackageGraph {
PackageGraph(this.entrypoint, this.lockFile, this.packages);
+ /// Creates a package graph using the data from [result].
+ ///
+ /// This is generally faster than loading a package graph from scratch, since
+ /// the packages' pubspecs are already fully-parsed.
+ factory PackageGraph.fromSolveResult(Entrypoint entrypoint,
+ SolveResult result) {
+ var packages = new Map.fromIterable(result.packages,
+ key: (id) => id.name,
+ value: (id) {
+ if (id.name == entrypoint.root.name) return entrypoint.root;
+
+ return new Package(result.pubspecs[id.name],
+ entrypoint.cache.sources[id.source].getDirectory(id));
+ });
+
+ return new PackageGraph(
+ entrypoint,
+ new LockFile(result.packages, entrypoint.cache.sources),
+ packages);
+ }
+
/// Loads the transformer cache for this graph.
///
/// This may only be called if [entrypoint] represents a physical package.
« no previous file with comments | « lib/src/global_packages.dart ('k') | lib/src/source/path.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698