Index: sdk/lib/_internal/pub/lib/src/solver/backtracking_solver.dart |
diff --git a/sdk/lib/_internal/pub/lib/src/solver/backtracking_solver.dart b/sdk/lib/_internal/pub/lib/src/solver/backtracking_solver.dart |
index 4c6033369bacd5a8e80cb974ac49e79548dede22..5aad7ad744fc650ef8d92806df86bb951dbec5b8 100644 |
--- a/sdk/lib/_internal/pub/lib/src/solver/backtracking_solver.dart |
+++ b/sdk/lib/_internal/pub/lib/src/solver/backtracking_solver.dart |
@@ -59,6 +59,7 @@ import 'version_solver.dart'; |
/// versions for speculative package selections. Backtracks and advances to the |
/// next potential solution in the case of a failure. |
class BacktrackingSolver { |
+ final SolveType type; |
final SourceRegistry sources; |
final Package root; |
@@ -73,9 +74,6 @@ class BacktrackingSolver { |
/// packages. |
final _forceLatest = new Set<String>(); |
- /// If this is set, the contents of [lockFile] are ignored while solving. |
- final bool _upgradeAll; |
- |
/// The set of packages whose dependecy is being overridden by the root |
/// package, keyed by the name of the package. |
/// |
@@ -109,11 +107,11 @@ class BacktrackingSolver { |
int get attemptedSolutions => _attemptedSolutions; |
var _attemptedSolutions = 1; |
- BacktrackingSolver(SourceRegistry sources, this.root, this.lockFile, |
- List<String> useLatest, {bool upgradeAll: false}) |
- : sources = sources, |
- cache = new PubspecCache(sources), |
- _upgradeAll = upgradeAll { |
+ BacktrackingSolver(SolveType type, SourceRegistry sources, this.root, |
+ this.lockFile, List<String> useLatest) |
+ : type = type, |
+ sources = sources, |
+ cache = new PubspecCache(type, sources) { |
for (var package in useLatest) { |
_forceLatest.add(package); |
} |
@@ -218,9 +216,17 @@ class BacktrackingSolver { |
/// |
/// Returns `null` if it isn't in the lockfile (or has been unlocked). |
PackageId getLocked(String package) { |
- if (_upgradeAll) return null; |
- if (_forceLatest.contains(package)) return null; |
+ if (type == SolveType.GET) return lockFile.packages[package]; |
+ |
+ // When downgrading, we don't want to force the latest versions of |
+ // non-hosted packages, since they don't support multiple versions and thus |
+ // can't be downgraded. |
Bob Nystrom
2014/07/09 18:19:00
Is this necessary? The behavior is the same with r
nweiz
2014/07/09 21:28:58
Not for git dependencies. It would be very weird i
Bob Nystrom
2014/07/10 17:46:11
That makes sense. I try to keep the version solver
nweiz
2014/07/14 21:52:05
Done. I used '.hasMultipleVersions' instead becaus
|
+ if (type == SolveType.DOWNGRADE) { |
+ var locked = lockFile.packages[package]; |
+ if (locked != null && locked.source != 'hosted') return locked; |
+ } |
+ if (_forceLatest.isEmpty || _forceLatest.contains(package)) return null; |
return lockFile.packages[package]; |
} |