Chromium Code Reviews| 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 cf7e5d08caef977e0c17e1494d6878d7a37f7f85..e2e60dc7bed4ba6fdf3a707eca97a08deecc520c 100644 |
| --- a/sdk/lib/_internal/pub/lib/src/entrypoint.dart |
| +++ b/sdk/lib/_internal/pub/lib/src/entrypoint.dart |
| @@ -109,60 +109,33 @@ class Entrypoint { |
| return future; |
| } |
| - /// Gets all dependencies of the [root] package, respecting the [LockFile] |
| - /// if present. |
| + /// Gets all dependencies of the [root] package. |
| /// |
| - /// Returns a [Future] that completes when all dependencies are available. |
| - Future getDependencies() { |
| - return new Future.sync(() { |
| - return resolveVersions(cache.sources, root, lockFile: loadLockFile()); |
| - }).then(_getDependencies); |
| - } |
| - |
| - /// Gets the latest available versions of all dependencies of the [root] |
| - /// package, writing a new [LockFile]. |
| + /// [useLatest], if provided, defines a list of packages that will be |
| + /// unlocked and upgraded to their latest versions. If [upgradeAll] is |
| + /// true, the previous lockfile is ignored and all packages are re-resolved |
| + /// from scratch. Otherwise, it will attempt to preserve the versions of all |
| + /// previously locked packages. |
|
nweiz
2013/12/11 06:48:32
It sounds like [useLatest] won't do anything if [u
Bob Nystrom
2013/12/11 22:36:59
They are actually orthogonal. useLatest *forces* t
|
| /// |
| - /// Returns a [Future] that completes when all dependencies are available. |
| - Future upgradeAllDependencies() { |
| - return resolveVersions(cache.sources, root).then(_getDependencies); |
| - } |
| - |
| - /// Gets the latest available versions of [dependencies], while leaving |
| - /// other dependencies as specified by the [LockFile] if possible. |
| + /// If [useLatest] is non-empty or [upgradeAll] is true, displays a detailed |
| + /// report of the changes made relative to the previous lockfile. |
|
nweiz
2013/12/11 06:48:32
Explain that this is a temporary situation. Ideall
Bob Nystrom
2013/12/11 22:36:59
Added a TODO below by the report code.
|
| /// |
| - /// Returns a [Future] that completes when all dependencies are available. |
| - Future upgradeDependencies(List<String> dependencies) { |
| - return new Future.sync(() { |
| - return resolveVersions(cache.sources, root, |
| - lockFile: loadLockFile(), useLatest: dependencies); |
| - }).then(_getDependencies); |
| - } |
| + /// Returns a [Future] that completes to the number of changed dependencies. |
| + /// It completes when all dependencies are available. |
| + Future<int> getDependencies({List<String> useLatest, bool upgradeAll}) { |
|
nweiz
2013/12/11 06:48:32
I don't think I like [getDependencies] as the name
Bob Nystrom
2013/12/11 22:36:59
Yeah, I'm not crazy about it either. Changed to "a
|
| + if (upgradeAll == null) upgradeAll = false; |
|
nweiz
2013/12/11 06:48:32
I like using explicit defaults for boolean paramet
Bob Nystrom
2013/12/11 22:36:59
That breaks forwarding. :(
upgradeAll is passed t
nweiz
2013/12/11 23:31:27
I don't think we should expect or support null for
Bob Nystrom
2013/12/12 00:14:58
OK, done.
|
| + |
| + var numChanged = 0; |
| - /// Removes the old packages directory, gets all dependencies listed in |
| - /// [result], and writes a [LockFile]. |
| - Future _getDependencies(SolveResult result) { |
| return new Future.sync(() { |
| + return resolveVersions(cache.sources, root, lockFile: loadLockFile(), |
| + useLatest: useLatest, upgradeAll: upgradeAll); |
| + }).then((result) { |
| if (!result.succeeded) throw result.error; |
| - // Warn the user if any overrides were in effect. |
| - if (result.overrides.isNotEmpty) { |
| - var buffer = new StringBuffer(); |
| - buffer.write("Warning: You are using these overridden dependencies:"); |
| - for (var override in result.overrides) { |
| - var source = cache.sources[override.source]; |
| - buffer.write("\n- ${override.name}"); |
| - if (override.constraint != VersionConstraint.any) { |
| - buffer.write(" version ${override.constraint}"); |
| - } |
| - if (source != cache.sources.defaultSource) { |
| - var description = source.formatDescription(root.dir, |
| - override.description); |
| - buffer.write(" (from ${override.source} $description)"); |
| - } |
| - } |
| - log.warning(buffer); |
| - } |
| + numChanged = result.showReport(showAll: useLatest != null || upgradeAll); |
| + // Install the packages. |
| cleanDir(packagesDir); |
| return Future.wait(result.packages.map((id) { |
| if (id.isRoot) return new Future.value(id); |
| @@ -172,6 +145,8 @@ class Entrypoint { |
| _saveLockFile(ids); |
| _linkSelf(); |
| _linkSecondaryPackageDirs(); |
| + |
| + return numChanged; |
| }); |
| } |