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

Unified Diff: utils/pub/packages_dir.dart

Issue 10399076: Get codebase ready for actually supporting versioning. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tiny tweak. Created 8 years, 7 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: utils/pub/packages_dir.dart
diff --git a/utils/pub/packages_dir.dart b/utils/pub/packages_dir.dart
index 04f8bd9a8208210a5cc7f6779988e309c722fd08..2770d4f91aaee80217214fe73a5a845c1fae7457 100644
--- a/utils/pub/packages_dir.dart
+++ b/utils/pub/packages_dir.dart
@@ -11,11 +11,6 @@
*/
class PackagesDir {
/**
- * The package containing this directory.
- */
- final Package owner;
-
- /**
* The system-wide cache which caches packages that need to be fetched over
* the network.
*/
@@ -32,15 +27,14 @@ class PackagesDir {
*/
final Map<PackageId, Future<Package>> _pendingInstalls;
- PackagesDir(this.owner, this.cache)
+ PackagesDir(this.path, this.cache)
: _loadedPackages = new Map<PackageId, Package>(),
_pendingInstalls = new Map<PackageId, Future<Package>>();
/**
- * Returns the path to the "packages" directory.
+ * The path to this "packages" directory.
*/
- // TODO(rnystrom): Make this path configurable.
- String get path() => join(owner.dir, 'packages');
+ final String path;
/**
* Ensures that the package identified by [id] is installed to the directory,
@@ -76,11 +70,10 @@ class PackagesDir {
return id.source.install(id, packageDir).transform((found) {
if (found) return null;
// TODO(nweiz): More robust error-handling.
- throw 'Package ${id.fullName} not found in source '
- '"${id.source.name}".';
+ throw 'Package ${id.name} not found in source "${id.source.name}".';
});
}
- }).chain((_) => Package.load(packageDir, cache.sources));
+ }).chain((_) => Package.load(packageDir, cache));
future.then((pkg) => _loadedPackages[id] = pkg);
always(future, () => _pendingInstalls.remove(id));
@@ -90,30 +83,26 @@ class PackagesDir {
}
/**
- * Installs the package identified by [id] and all its transitive
- * dependencies.
+ * Installs all of the packages referred to by [packages] and their transitive
+ * dependencies. References are resolved using [entrypoint].
*/
- Future<Package> installTransitively(PackageId id) {
+ Future installTransitively(Package entrypoint,
+ List<PackageRef> packages) {
var seen = new Set<PackageId>();
- Future<Package> helper(id) {
- if (seen.contains(id)) return new Future.immediate(null);
- seen.add(id);
- return install(id).chain((package) {
- return Futures.wait(package.dependencies.map(helper)).
- transform((_) => package);
- });
- }
+ Future helper(List<PackageRef> packages) {
+ return Futures.wait(packages.map((ref) {
+ return entrypoint.resolve(ref).chain((id) {
+ if (seen.contains(id)) return new Future.immediate(null);
+ seen.add(id);
- return helper(id);
- }
+ return install(id).chain((package) {
+ return helper(package.dependencies);
+ });
+ });
+ }));
+ }
- /**
- * Installs all dependencies of [owner] to the "packages" directory. Returns a
- * [Future] that completes when all dependencies are installed.
- */
- Future installDependencies() {
- return Futures.wait(owner.dependencies.map(installTransitively)).
- transform((_) => null);
+ return helper(packages);
}
}

Powered by Google App Engine
This is Rietveld 408576698