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

Side by Side Diff: lib/src/command/cache_add.dart

Issue 2079303003: Track Source objects in PackageNames. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Code review changes Created 4 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
« no previous file with comments | « lib/src/command/build.dart ('k') | lib/src/command/cache_repair.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 import 'dart:async'; 5 import 'dart:async';
6 6
7 import 'package:pub_semver/pub_semver.dart'; 7 import 'package:pub_semver/pub_semver.dart';
8 8
9 import '../command.dart'; 9 import '../command.dart';
10 import '../log.dart' as log; 10 import '../log.dart' as log;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 var constraint = VersionConstraint.any; 46 var constraint = VersionConstraint.any;
47 if (argResults["version"] != null) { 47 if (argResults["version"] != null) {
48 try { 48 try {
49 constraint = new VersionConstraint.parse(argResults["version"]); 49 constraint = new VersionConstraint.parse(argResults["version"]);
50 } on FormatException catch (error) { 50 } on FormatException catch (error) {
51 usageException(error.message); 51 usageException(error.message);
52 } 52 }
53 } 53 }
54 54
55 // TODO(rnystrom): Support installing from git too. 55 // TODO(rnystrom): Support installing from git too.
56 var source = cache.source("hosted"); 56 var source = cache.hosted;
57 57
58 // TODO(rnystrom): Allow specifying the server. 58 // TODO(rnystrom): Allow specifying the server.
59 var ids = (await source.getVersions(cache.sources.hosted.refFor(package))) 59 var ids = (await source.getVersions(cache.sources.hosted.refFor(package)))
60 .where((id) => constraint.allows(id.version)) 60 .where((id) => constraint.allows(id.version))
61 .toList(); 61 .toList();
62 62
63 if (ids.isEmpty) { 63 if (ids.isEmpty) {
64 // TODO(rnystrom): Show most recent unmatching version? 64 // TODO(rnystrom): Show most recent unmatching version?
65 fail("Package $package has no versions that match $constraint."); 65 fail("Package $package has no versions that match $constraint.");
66 } 66 }
(...skipping 14 matching lines...) Expand all
81 // Install them in ascending order. 81 // Install them in ascending order.
82 ids.sort((id1, id2) => id1.version.compareTo(id2.version)); 82 ids.sort((id1, id2) => id1.version.compareTo(id2.version));
83 await Future.forEach(ids, downloadVersion); 83 await Future.forEach(ids, downloadVersion);
84 } else { 84 } else {
85 // Pick the best matching version. 85 // Pick the best matching version.
86 ids.sort((id1, id2) => Version.prioritize(id1.version, id2.version)); 86 ids.sort((id1, id2) => Version.prioritize(id1.version, id2.version));
87 await downloadVersion(ids.last); 87 await downloadVersion(ids.last);
88 } 88 }
89 } 89 }
90 } 90 }
OLDNEW
« no previous file with comments | « lib/src/command/build.dart ('k') | lib/src/command/cache_repair.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698