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

Unified Diff: sdk/lib/_internal/pub/lib/src/package_graph.dart

Issue 576333002: Precompile immutable dependencies on "pub get". (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 6 years, 3 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 | « sdk/lib/_internal/pub/lib/src/entrypoint.dart ('k') | sdk/lib/_internal/pub/lib/src/utils.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/package_graph.dart
diff --git a/sdk/lib/_internal/pub/lib/src/package_graph.dart b/sdk/lib/_internal/pub/lib/src/package_graph.dart
index c82a6fb1cdf649a97de09693e966520c6dba03f1..6066334f975bbed157fe1a9784d03270a3669bd4 100644
--- a/sdk/lib/_internal/pub/lib/src/package_graph.dart
+++ b/sdk/lib/_internal/pub/lib/src/package_graph.dart
@@ -8,6 +8,8 @@ import 'barback/transformer_cache.dart';
import 'entrypoint.dart';
import 'lock_file.dart';
import 'package.dart';
+import 'source/cached.dart';
+import 'source/hosted.dart';
import 'utils.dart';
/// A holistic view of the entire transitive dependency graph for an entrypoint.
@@ -66,4 +68,28 @@ class PackageGraph {
return _transitiveDependencies[package];
}
+
+ /// Returns whether [package] is mutable.
+ ///
+ /// A package is considered to be mutable if it or any of its dependencies
+ /// don't come from a cached source, since the user can change its contents
+ /// without modifying the pub cache. Information generated from mutable
+ /// packages is generally not safe to cache, since it may change frequently.
+ bool isPackageMutable(String package) {
+ var id = lockFile.packages[package];
+ if (id == null) return true;
+
+ var source = entrypoint.cache.sources[id.source];
+ if (source is! CachedSource) return true;
+
+ return transitiveDependencies(package).any((dep) {
+ var depId = lockFile.packages[dep.name];
+
+ // The entrypoint package doesn't have a lockfile entry. It's always
+ // mutable.
+ if (depId == null) return true;
+
+ return entrypoint.cache.sources[depId.source] is! CachedSource;
+ });
+ }
}
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/entrypoint.dart ('k') | sdk/lib/_internal/pub/lib/src/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698