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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library pub.package_graph; 5 library pub.package_graph;
6 6
7 import 'barback/transformer_cache.dart'; 7 import 'barback/transformer_cache.dart';
8 import 'entrypoint.dart'; 8 import 'entrypoint.dart';
9 import 'lock_file.dart'; 9 import 'lock_file.dart';
10 import 'package.dart'; 10 import 'package.dart';
11 import 'source/cached.dart';
12 import 'source/hosted.dart';
11 import 'utils.dart'; 13 import 'utils.dart';
12 14
13 /// A holistic view of the entire transitive dependency graph for an entrypoint. 15 /// A holistic view of the entire transitive dependency graph for an entrypoint.
14 /// 16 ///
15 /// A package graph can be loaded using [Entrypoint.loadPackageGraph]. 17 /// A package graph can be loaded using [Entrypoint.loadPackageGraph].
16 class PackageGraph { 18 class PackageGraph {
17 /// The entrypoint. 19 /// The entrypoint.
18 final Entrypoint entrypoint; 20 final Entrypoint entrypoint;
19 21
20 /// The entrypoint's lockfile. 22 /// The entrypoint's lockfile.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 61
60 if (_transitiveDependencies == null) { 62 if (_transitiveDependencies == null) {
61 var closure = transitiveClosure(mapMap(packages, 63 var closure = transitiveClosure(mapMap(packages,
62 value: (_, package) => package.dependencies.map((dep) => dep.name))); 64 value: (_, package) => package.dependencies.map((dep) => dep.name)));
63 _transitiveDependencies = mapMap(closure, 65 _transitiveDependencies = mapMap(closure,
64 value: (_, names) => names.map((name) => packages[name]).toSet()); 66 value: (_, names) => names.map((name) => packages[name]).toSet());
65 } 67 }
66 68
67 return _transitiveDependencies[package]; 69 return _transitiveDependencies[package];
68 } 70 }
71
72 /// Returns whether [package] is mutable.
73 ///
74 /// A package is considered to be mutable if it or any of its dependencies
75 /// don't come from a cached source, since the user can change its contents
76 /// without modifying the pub cache. Information generated from mutable
77 /// packages is generally not safe to cache, since it may change frequently.
78 bool isPackageMutable(String package) {
79 var id = lockFile.packages[package];
80 if (id == null) return true;
81
82 var source = entrypoint.cache.sources[id.source];
83 if (source is! CachedSource) return true;
84
85 return transitiveDependencies(package).any((dep) {
86 var depId = lockFile.packages[dep.name];
87
88 // The entrypoint package doesn't have a lockfile entry. It's always
89 // mutable.
90 if (depId == null) return true;
91
92 return entrypoint.cache.sources[depId.source] is! CachedSource;
93 });
94 }
69 } 95 }
OLDNEW
« 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