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 pub_upgrade_test; | 5 library pub_upgrade_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:pub/src/lock_file.dart'; | 9 import 'package:pub/src/lock_file.dart'; |
10 import 'package:pub/src/log.dart' as log; | 10 import 'package:pub/src/log.dart' as log; |
(...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1388 MockSource(this.name); | 1388 MockSource(this.name); |
1389 | 1389 |
1390 dynamic parseDescription(String containingPath, description, | 1390 dynamic parseDescription(String containingPath, description, |
1391 {bool fromLockFile: false}) => description; | 1391 {bool fromLockFile: false}) => description; |
1392 | 1392 |
1393 bool descriptionsEqual(description1, description2) => | 1393 bool descriptionsEqual(description1, description2) => |
1394 description1 == description2; | 1394 description1 == description2; |
1395 | 1395 |
1396 String getDirectory(PackageId id) => '${id.name}-${id.version}'; | 1396 String getDirectory(PackageId id) => '${id.name}-${id.version}'; |
1397 | 1397 |
1398 Future<List<Pubspec>> getVersions(String name, String description) { | 1398 Future<List<PackageId>> doGetVersions(PackageRef ref) async { |
1399 return new Future.sync(() { | 1399 // Make sure the solver doesn't request the same thing twice. |
1400 // Make sure the solver doesn't request the same thing twice. | 1400 if (_requestedVersions.contains(ref.description)) { |
1401 if (_requestedVersions.contains(description)) { | 1401 throw new Exception('Version list for $description was already ' |
1402 throw new Exception('Version list for $description was already ' | 1402 'requested.'); |
1403 'requested.'); | 1403 } |
1404 } | |
1405 | 1404 |
1406 _requestedVersions.add(description); | 1405 _requestedVersions.add(ref.description); |
1407 | 1406 |
1408 if (!_packages.containsKey(description)){ | 1407 if (!_packages.containsKey(ref.description)){ |
1409 throw new Exception('MockSource does not have a package matching ' | 1408 throw new Exception('MockSource does not have a package matching ' |
1410 '"$description".'); | 1409 '"${ref.description}".'); |
1411 } | 1410 } |
1412 | 1411 |
1413 return _packages[description].values | 1412 return _packages[ref.description].values |
1414 .map((package) => package.pubspec).toList(); | 1413 .map((package) => ref.atVersion(package.version)).toList(); |
1415 }); | |
1416 } | 1414 } |
1417 | 1415 |
1418 Future<Pubspec> describeUncached(PackageId id) { | 1416 Future<Pubspec> describeUncached(PackageId id) { |
1419 return new Future.sync(() { | 1417 return new Future.sync(() { |
1420 // Make sure the solver doesn't request the same thing twice. | 1418 // Make sure the solver doesn't request the same thing twice. |
1421 if (_requestedPubspecs.containsKey(id.description) && | 1419 if (_requestedPubspecs.containsKey(id.description) && |
1422 _requestedPubspecs[id.description].contains(id.version)) { | 1420 _requestedPubspecs[id.description].contains(id.version)) { |
1423 throw new Exception('Pubspec for $id was already requested.'); | 1421 throw new Exception('Pubspec for $id was already requested.'); |
1424 } | 1422 } |
1425 | 1423 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1531 } | 1529 } |
1532 | 1530 |
1533 var source = "mock1"; | 1531 var source = "mock1"; |
1534 if (match[7] != null) { | 1532 if (match[7] != null) { |
1535 source = match[7]; | 1533 source = match[7]; |
1536 if (source == "root") source = null; | 1534 if (source == "root") source = null; |
1537 } | 1535 } |
1538 | 1536 |
1539 return new PackageId(name, source, parsedVersion, description); | 1537 return new PackageId(name, source, parsedVersion, description); |
1540 } | 1538 } |
OLD | NEW |