 Chromium Code Reviews
 Chromium Code Reviews Issue 10540151:
  First pass at version constraint solver.  (Closed) 
  Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
    
  
    Issue 10540151:
  First pass at version constraint solver.  (Closed) 
  Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart| OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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('source'); | 5 #library('source'); | 
| 6 | 6 | 
| 7 #import('package.dart'); | 7 #import('package.dart'); | 
| 8 | 8 | 
| 9 /** | 9 /** | 
| 10 * A source from which to install packages. | 10 * A source from which to install packages. | 
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 * Whether this source's packages should be cached in Pub's global cache | 23 * Whether this source's packages should be cached in Pub's global cache | 
| 24 * directory. | 24 * directory. | 
| 25 * | 25 * | 
| 26 * A source should be cached if it requires network access to retrieve | 26 * A source should be cached if it requires network access to retrieve | 
| 27 * packages. It doesn't need to be cached if all packages are available | 27 * packages. It doesn't need to be cached if all packages are available | 
| 28 * locally. | 28 * locally. | 
| 29 */ | 29 */ | 
| 30 abstract bool get shouldCache(); | 30 abstract bool get shouldCache(); | 
| 31 | 31 | 
| 32 /** | 32 /** | 
| 33 * Finds the best known version of package [name] that meets [constraint]. | |
| 34 * | |
| 35 * Note that this does *not* require the packages to be installed, which is | |
| 36 * the point. This is used during version resolution to determine which | |
| 37 * package versions are available to be installed (or already installed). | |
| 38 */ | |
| 39 Future<Version> findVersion(String name, | |
| 
nweiz
2012/06/18 18:29:19
Shouldn't "name" be "description" instead?
 
Bob Nystrom
2012/06/20 01:40:04
Yeah. Right now, this giant patch punts on how dif
 
nweiz
2012/06/20 21:08:48
Sure, it's reasonable to put this off.
 | |
| 40 VersionConstraint constraint) { | |
| 
nweiz
2012/06/18 18:29:19
This puts a lot of burden onto the sources for und
 
Bob Nystrom
2012/06/20 01:40:04
Maybe I'm being premature, but I worry that that c
 
nweiz
2012/06/20 21:08:48
If we do pass VersionConstraints to sources, we sh
 
Bob Nystrom
2012/06/20 22:29:54
My intent is that that caching would live outside
 
nweiz
2012/06/20 23:47:45
My point is that if the source receives findVersio
 
Bob Nystrom
2012/06/21 00:12:18
Ah, sorry. I see what you're getting at. I forgot
 | |
| 41 // TODO(rnystrom): Do something better here. | |
| 42 throw "Source $name doesn't support versioning."; | |
| 43 } | |
| 44 | |
| 45 /** | |
| 46 * Loads the (possibly remote) pubspec for the desired [version] of the named | |
| 47 * [package]. This will be called for packages that have not yet been | |
| 48 * installed during the version resolution process. | |
| 49 */ | |
| 50 Future<Pubspec> describe(String package, Version version) { | |
| 51 // TODO(rnystrom): Figure out how non-default sources should handle this. | |
| 52 throw "Source $name doesn't support versioning."; | |
| 53 } | |
| 54 | |
| 55 /** | |
| 33 * Installs the package identified by [id] to [path]. Returns a [Future] that | 56 * Installs the package identified by [id] to [path]. Returns a [Future] that | 
| 34 * completes when the installation was finished. The [Future] should resolve | 57 * completes when the installation was finished. The [Future] should resolve | 
| 35 * to true if the package was found in the source and false if it wasn't. For | 58 * to true if the package was found in the source and false if it wasn't. For | 
| 36 * all other error conditions, it should complete with an exception. | 59 * all other error conditions, it should complete with an exception. | 
| 37 * | 60 * | 
| 38 * If [shouldCache] is true, [path] will be a path to this source's | 61 * If [shouldCache] is true, [path] will be a path to this source's | 
| 39 * subdirectory of the [PackageCache]'s cache directory. If [shouldCache] is | 62 * subdirectory of the [PackageCache]'s cache directory. If [shouldCache] is | 
| 40 * false, [path] will be a path to the application's "packages" directory. | 63 * false, [path] will be a path to the application's "packages" directory. | 
| 41 * | 64 * | 
| 42 * [path] is guaranteed not to exist, and its parent directory is guaranteed | 65 * [path] is guaranteed not to exist, and its parent directory is guaranteed | 
| (...skipping 13 matching lines...) Expand all Loading... | |
| 56 /** | 79 /** | 
| 57 * Returns a human-friendly name for the package identified by [id]. This | 80 * Returns a human-friendly name for the package identified by [id]. This | 
| 58 * method should be light-weight. It doesn't need to validate that the given | 81 * method should be light-weight. It doesn't need to validate that the given | 
| 59 * package exists. | 82 * package exists. | 
| 60 * | 83 * | 
| 61 * The package name should be lower-case and suitable for use in a filename. | 84 * The package name should be lower-case and suitable for use in a filename. | 
| 62 * It may contain forward slashes. | 85 * It may contain forward slashes. | 
| 63 */ | 86 */ | 
| 64 String packageName(PackageId id) => id.description; | 87 String packageName(PackageId id) => id.description; | 
| 65 } | 88 } | 
| OLD | NEW |