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

Side by Side Diff: sdk/lib/_internal/pub/lib/src/global_packages.dart

Issue 365993007: Support "pub downgrade". (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 pub.global_packages; 5 library pub.global_packages;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert';
9 import 'dart:io'; 8 import 'dart:io';
10 9
11 import 'package:path/path.dart' as p; 10 import 'package:path/path.dart' as p;
12 11
13 import 'entrypoint.dart'; 12 import 'entrypoint.dart';
14 import 'io.dart'; 13 import 'io.dart';
15 import 'lock_file.dart'; 14 import 'lock_file.dart';
16 import 'log.dart' as log; 15 import 'log.dart' as log;
17 import 'package.dart'; 16 import 'package.dart';
18 import 'system_cache.dart'; 17 import 'system_cache.dart';
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 70
72 var package; 71 var package;
73 var id; 72 var id;
74 return _selectVersion(name, currentVersion, constraint).then((version) { 73 return _selectVersion(name, currentVersion, constraint).then((version) {
75 // Make sure it's in the cache. 74 // Make sure it's in the cache.
76 id = new PackageId(name, _source.name, version, name); 75 id = new PackageId(name, _source.name, version, name);
77 return _source.downloadToSystemCache(id); 76 return _source.downloadToSystemCache(id);
78 }).then((p) { 77 }).then((p) {
79 package = p; 78 package = p;
80 // Resolve it and download its dependencies. 79 // Resolve it and download its dependencies.
81 return resolveVersions(cache.sources, package, lockFile: lockFile); 80 return resolveVersions(SolveType.GET, cache.sources, package,
81 lockFile: lockFile);
82 }).then((result) { 82 }).then((result) {
83 if (!result.succeeded) throw result.error; 83 if (!result.succeeded) throw result.error;
84 result.showReport(); 84 result.showReport(SolveType.GET);
85 85
86 // Make sure all of the dependencies are locally installed. 86 // Make sure all of the dependencies are locally installed.
87 return Future.wait(result.packages.map((id) { 87 return Future.wait(result.packages.map((id) {
88 var source = cache.sources[id.source]; 88 var source = cache.sources[id.source];
89 if (source is! CachedSource) return new Future.value(); 89 if (source is! CachedSource) return new Future.value();
90 return source.downloadToSystemCache(id) 90 return source.downloadToSystemCache(id)
91 .then((_) => source.resolveId(id)); 91 .then((_) => source.resolveId(id));
92 })); 92 }));
93 }).then((ids) { 93 }).then((ids) {
94 var lockFile = new LockFile(ids); 94 var lockFile = new LockFile(ids);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 174
175 // Pick the best matching version. 175 // Pick the best matching version.
176 versions.sort(Version.prioritize); 176 versions.sort(Version.prioritize);
177 return versions.last; 177 return versions.last;
178 }); 178 });
179 } 179 }
180 180
181 /// Gets the path to the lock file for an activated package with [name]. 181 /// Gets the path to the lock file for an activated package with [name].
182 String _getLockFilePath(name) => p.join(_directory, name + ".lock"); 182 String _getLockFilePath(name) => p.join(_directory, name + ".lock");
183 } 183 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698