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

Unified Diff: utils/pub/source.dart

Issue 10690127: Add support to the version solver for sources that only have a single version per package. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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/source.dart
diff --git a/utils/pub/source.dart b/utils/pub/source.dart
index 236aa9a5eb2897c8637bbfa3ccf42805cb957c61..acd06f032da8e03b843088dd931a9c62a08f64c4 100644
--- a/utils/pub/source.dart
+++ b/utils/pub/source.dart
@@ -71,20 +71,27 @@ class Source {
* Note that this does *not* require the packages to be installed, which is
* the point. This is used during version resolution to determine which
* package versions are available to be installed (or already installed).
+ *
+ * By default, this assumes that each description has a single version and
+ * uses [describe] to get that version.
*/
Future<List<Version>> getVersions(description) {
- // TODO(rnystrom): Do something better here.
- throw "Source $name doesn't support versioning.";
+ return describe(new PackageId(this, Version.none, description))
+ .transform((pubspec) => [pubspec.version]);
}
/**
* Loads the (possibly remote) pubspec for the package version identified by
- * [id]. This will be called for packages that have not yet been installed
+ * [id]. This may be called for packages that have not yet been installed
* during the version resolution process.
+ *
+ * For cached sources, by default this uses [installToSystemCache] to get the
+ * pubspec. There is no default implementation for non-cached sources; they
+ * must implement it manually.
*/
Future<Pubspec> describe(PackageId id) {
- // TODO(rnystrom): Figure out how non-default sources should handle this.
- throw "Source $name doesn't support versioning.";
+ if (!shouldCache) throw "Source $name must implement describe(id).";
+ return installToSystemCache(id).transform((package) => package.pubspec);
}
/**

Powered by Google App Engine
This is Rietveld 408576698