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

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

Issue 331593012: Add a "global activate" command to pub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. Created 6 years, 6 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/entrypoint.dart
diff --git a/sdk/lib/_internal/pub/lib/src/entrypoint.dart b/sdk/lib/_internal/pub/lib/src/entrypoint.dart
index 3eeeebd1d43d8127bb83102eae169d39e064eec3..51f05a7a5018afa2cc304a5287f7a5180f645760 100644
--- a/sdk/lib/_internal/pub/lib/src/entrypoint.dart
+++ b/sdk/lib/_internal/pub/lib/src/entrypoint.dart
@@ -43,13 +43,6 @@ class Entrypoint {
/// the network.
final SystemCache cache;
- /// A map of the [Future]s that were or are being used to asynchronously get
- /// packages.
- ///
- /// Includes packages that are in-transit and ones that have already
- /// completed.
- final _pendingGets = new Map<PackageId, Future<PackageId>>();
-
/// Loads the entrypoint from a package at [rootDir].
Entrypoint(String rootDir, SystemCache cache)
: root = new Package.load(null, rootDir, cache.sources),
@@ -94,7 +87,7 @@ class Entrypoint {
// Install the packages.
cleanDir(packagesDir);
- return Future.wait(result.packages.map(_get).toList()).then((ids) {
+ return Future.wait(result.packages.map(_get)).then((ids) {
_saveLockFile(ids);
_linkSelf();
_linkSecondaryPackageDirs();
@@ -111,20 +104,11 @@ class Entrypoint {
Future<PackageId> _get(PackageId id) {
if (id.isRoot) return new Future.value(id);
- var pending = _pendingGets[id];
- if (pending != null) return pending;
-
- var future = syncFuture(() {
- var packageDir = path.join(packagesDir, id.name);
- if (entryExists(packageDir)) deleteEntry(packageDir);
-
- var source = cache.sources[id.source];
- return source.get(id, packageDir).then((_) => source.resolveId(id));
- });
-
- _pendingGets[id] = future;
+ var packageDir = path.join(packagesDir, id.name);
+ if (entryExists(packageDir)) deleteEntry(packageDir);
- return future;
+ var source = cache.sources[id.source];
+ return source.get(id, packageDir).then((_) => source.resolveId(id));
}
/// Loads the list of concrete package versions from the `pubspec.lock`, if it
@@ -245,11 +229,7 @@ class Entrypoint {
/// Saves a list of concrete package versions to the `pubspec.lock` file.
void _saveLockFile(List<PackageId> packageIds) {
- var lockFile = new LockFile.empty();
- for (var id in packageIds) {
- if (!id.isRoot) lockFile.packages[id.name] = id;
- }
-
+ var lockFile = new LockFile(packageIds);
var lockFilePath = path.join(root.dir, 'pubspec.lock');
writeTextFile(lockFilePath, lockFile.serialize(root.dir, cache.sources));
}

Powered by Google App Engine
This is Rietveld 408576698