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

Side by Side Diff: utils/pub/version_solver.dart

Issue 10829459: Deprecate Math object in corelib in favor of dart:math library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 8 years, 4 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
« no previous file with comments | « utils/pub/version.dart ('k') | utils/pub/yaml/yaml.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) 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 /** 5 /**
6 * Attempts to resolve a set of version constraints for a package dependency 6 * Attempts to resolve a set of version constraints for a package dependency
7 * graph and select an appropriate set of best specific versions for all 7 * graph and select an appropriate set of best specific versions for all
8 * dependent packages. It works iteratively and tries to reach a stable 8 * dependent packages. It works iteratively and tries to reach a stable
9 * solution where the constraints of all dependencies are met. If it fails to 9 * solution where the constraints of all dependencies are met. If it fails to
10 * reach a solution after a certain number of iterations, it assumes the 10 * reach a solution after a certain number of iterations, it assumes the
(...skipping 20 matching lines...) Expand all
31 * of the constraints that its depending packages place on it. If that overall 31 * of the constraints that its depending packages place on it. If that overall
32 * constraint changes (say from "<3.0.0" to "<2.5.0"), then the currently 32 * constraint changes (say from "<3.0.0" to "<2.5.0"), then the currently
33 * picked version for that package may fall outside of the new constraint. If 33 * picked version for that package may fall outside of the new constraint. If
34 * that happens, we find the new best version that meets the updated constraint 34 * that happens, we find the new best version that meets the updated constraint
35 * and then the change the package to use that version. That cycles back up to 35 * and then the change the package to use that version. That cycles back up to
36 * the beginning again. 36 * the beginning again.
37 */ 37 */
38 #library('version_solver'); 38 #library('version_solver');
39 39
40 #import('dart:json'); 40 #import('dart:json');
41 #import('dart:math');
41 #import('lock_file.dart'); 42 #import('lock_file.dart');
42 #import('package.dart'); 43 #import('package.dart');
43 #import('pubspec.dart'); 44 #import('pubspec.dart');
44 #import('root_source.dart'); 45 #import('root_source.dart');
45 #import('source.dart'); 46 #import('source.dart');
46 #import('source_registry.dart'); 47 #import('source_registry.dart');
47 #import('utils.dart'); 48 #import('utils.dart');
48 #import('version.dart'); 49 #import('version.dart');
49 50
50 /** 51 /**
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // Stop if we are done. 102 // Stop if we are done.
102 if (_work.isEmpty()) return new Future.immediate(buildResults()); 103 if (_work.isEmpty()) return new Future.immediate(buildResults());
103 104
104 // If we appear to be stuck in a loop, then we probably have an unstable 105 // If we appear to be stuck in a loop, then we probably have an unstable
105 // graph, bail. We guess this based on a rough heuristic that it should 106 // graph, bail. We guess this based on a rough heuristic that it should
106 // only take a certain number of steps to solve a graph with a given 107 // only take a certain number of steps to solve a graph with a given
107 // number of connections. 108 // number of connections.
108 // TODO(rnystrom): These numbers here are magic and arbitrary. Tune 109 // TODO(rnystrom): These numbers here are magic and arbitrary. Tune
109 // when we have a better picture of real-world package topologies. 110 // when we have a better picture of real-world package topologies.
110 _numIterations++; 111 _numIterations++;
111 if (_numIterations > Math.max(50, _packages.length * 5)) { 112 if (_numIterations > max(50, _packages.length * 5)) {
112 throw new CouldNotSolveException(); 113 throw new CouldNotSolveException();
113 } 114 }
114 115
115 // Run the first work item. 116 // Run the first work item.
116 var future = _work.removeFirst().process(this); 117 var future = _work.removeFirst().process(this);
117 118
118 // If we have an async operation to perform, chain the loop to resume 119 // If we have an async operation to perform, chain the loop to resume
119 // when it's done. Otherwise, just loop synchronously. 120 // when it's done. Otherwise, just loop synchronously.
120 if (future != null) { 121 if (future != null) {
121 return future.chain(processNextWorkItem); 122 return future.chain(processNextWorkItem);
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 final description1; 700 final description1;
700 final description2; 701 final description2;
701 702
702 DescriptionMismatchException(this.package, this.description1, 703 DescriptionMismatchException(this.package, this.description1,
703 this.description2); 704 this.description2);
704 705
705 // TODO(nweiz): Dump to YAML when that's supported 706 // TODO(nweiz): Dump to YAML when that's supported
706 String toString() => "Package '$package' has conflicting descriptions " 707 String toString() => "Package '$package' has conflicting descriptions "
707 "'${JSON.stringify(description1)}' and '${JSON.stringify(description2)}'"; 708 "'${JSON.stringify(description1)}' and '${JSON.stringify(description2)}'";
708 } 709 }
OLDNEW
« no previous file with comments | « utils/pub/version.dart ('k') | utils/pub/yaml/yaml.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698