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

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

Issue 13095015: Use backtracking when solving dependency constraints. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Allow both solvers to coexist. Created 7 years, 8 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 | « no previous file | utils/pub/log.dart » ('j') | utils/pub/version_solver.dart » ('J')
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 library entrypoint; 5 library entrypoint;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import '../../pkg/pathos/lib/path.dart' as path; 9 import '../../pkg/pathos/lib/path.dart' as path;
10 10
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 _installs[id] = future; 96 _installs[id] = future;
97 97
98 return future; 98 return future;
99 } 99 }
100 100
101 /// Installs all dependencies of the [root] package to its "packages" 101 /// Installs all dependencies of the [root] package to its "packages"
102 /// directory, respecting the [LockFile] if present. Returns a [Future] that 102 /// directory, respecting the [LockFile] if present. Returns a [Future] that
103 /// completes when all dependencies are installed. 103 /// completes when all dependencies are installed.
104 Future installDependencies() { 104 Future installDependencies() {
105 return defer(() { 105 return defer(() {
106 return resolveVersions(cache.sources, root, loadLockFile()); 106 return resolveVersions(cache.sources, root, lockFile: loadLockFile());
107 }).then(_installDependencies); 107 }).then(_installDependencies);
108 } 108 }
109 109
110 /// Installs the latest available versions of all dependencies of the [root] 110 /// Installs the latest available versions of all dependencies of the [root]
111 /// package to its "package" directory, writing a new [LockFile]. Returns a 111 /// package to its "package" directory, writing a new [LockFile]. Returns a
112 /// [Future] that completes when all dependencies are installed. 112 /// [Future] that completes when all dependencies are installed.
113 Future updateAllDependencies() { 113 Future updateAllDependencies() {
114 return resolveVersions(cache.sources, root, new LockFile.empty()) 114 return resolveVersions(cache.sources, root).then(_installDependencies);
115 .then(_installDependencies);
116 } 115 }
117 116
118 /// Installs the latest available versions of [dependencies], while leaving 117 /// Installs the latest available versions of [dependencies], while leaving
119 /// other dependencies as specified by the [LockFile] if possible. Returns a 118 /// other dependencies as specified by the [LockFile] if possible. Returns a
120 /// [Future] that completes when all dependencies are installed. 119 /// [Future] that completes when all dependencies are installed.
121 Future updateDependencies(List<String> dependencies) { 120 Future updateDependencies(List<String> dependencies) {
122 return defer(() { 121 return defer(() {
123 var solver = new VersionSolver(cache.sources, root, loadLockFile()); 122 return resolveVersions(cache.sources, root,
124 for (var dependency in dependencies) { 123 lockFile: loadLockFile(), useLatest: dependencies);
125 solver.useLatestVersion(dependency);
126 }
127 return solver.solve();
128 }).then(_installDependencies); 124 }).then(_installDependencies);
129 } 125 }
130 126
131 /// Removes the old packages directory, installs all dependencies listed in 127 /// Removes the old packages directory, installs all dependencies listed in
132 /// [packageVersions], and writes a [LockFile]. 128 /// [packageVersions], and writes a [LockFile].
133 Future _installDependencies(List<PackageId> packageVersions) { 129 Future _installDependencies(List<PackageId> packageVersions) {
134 return new Future.of(() { 130 return new Future.of(() {
135 cleanDir(packagesDir); 131 cleanDir(packagesDir);
136 return Future.wait(packageVersions.map((id) { 132 return Future.wait(packageVersions.map((id) {
137 if (id.isRoot) return new Future.immediate(id); 133 if (id.isRoot) return new Future.immediate(id);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 /// Creates a symlink to the `packages` directory in [dir]. Will replace one 292 /// Creates a symlink to the `packages` directory in [dir]. Will replace one
297 /// if already there. 293 /// if already there.
298 Future _linkSecondaryPackageDir(String dir) { 294 Future _linkSecondaryPackageDir(String dir) {
299 return defer(() { 295 return defer(() {
300 var symlink = path.join(dir, 'packages'); 296 var symlink = path.join(dir, 'packages');
301 if (entryExists(symlink)) deleteEntry(symlink); 297 if (entryExists(symlink)) deleteEntry(symlink);
302 return createSymlink(packagesDir, symlink, relative: true); 298 return createSymlink(packagesDir, symlink, relative: true);
303 }); 299 });
304 } 300 }
305 } 301 }
OLDNEW
« no previous file with comments | « no previous file | utils/pub/log.dart » ('j') | utils/pub/version_solver.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698