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

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

Issue 13095015: Use backtracking when solving dependency constraints. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Clean up some test code. 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 path_source; 5 library path_source;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import '../../pkg/pathos/lib/path.dart' as path; 10 import '../../pkg/pathos/lib/path.dart' as path;
(...skipping 15 matching lines...) Expand all
26 26
27 Future<Pubspec> describe(PackageId id) { 27 Future<Pubspec> describe(PackageId id) {
28 return defer(() { 28 return defer(() {
29 _validatePath(id.name, id.description); 29 _validatePath(id.name, id.description);
30 return new Pubspec.load(id.name, id.description["path"], 30 return new Pubspec.load(id.name, id.description["path"],
31 systemCache.sources); 31 systemCache.sources);
32 }); 32 });
33 } 33 }
34 34
35 bool descriptionsEqual(description1, description2) { 35 bool descriptionsEqual(description1, description2) {
36 // Compare real paths after normalizing and resolving symlinks. 36 try {
nweiz 2013/03/29 01:58:25 I don't understand why this change is in this CL.
Bob Nystrom 2013/03/30 00:15:55 The previous code will fail if you call descriptio
37 var path1 = new File(description1["path"]).fullPathSync(); 37 // Compare real paths after normalizing and resolving symlinks.
38 var path2 = new File(description2["path"]).fullPathSync(); 38 var path1 = new File(description1["path"]).fullPathSync();
39 return path1 == path2; 39 var path2 = new File(description2["path"]).fullPathSync();
40 return path1 == path2;
41 } on FileIOException catch (ex) {
42 // If either of the files couldn't be found, fallback to just comparing
nweiz 2013/03/29 01:58:25 "fallback" -> "fall back"
Bob Nystrom 2013/03/30 00:15:55 Done.
43 // the normalized paths.
44 var path1 = path.normalize(description1["path"]);
45 var path2 = path.normalize(description2["path"]);
nweiz 2013/03/29 01:58:25 Shouldn't you make these absolute here?
Bob Nystrom 2013/03/30 00:15:55 Done.
46 return path1 == path2;
47 }
40 } 48 }
41 49
42 Future<bool> install(PackageId id, String destination) { 50 Future<bool> install(PackageId id, String destination) {
43 return defer(() { 51 return defer(() {
44 try { 52 try {
45 _validatePath(id.name, id.description); 53 _validatePath(id.name, id.description);
46 } on FormatException catch(err) { 54 } on FormatException catch(err) {
47 return false; 55 return false;
48 } 56 }
49 57
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 // confused as files. 120 // confused as files.
113 if (fileExists(dir)) { 121 if (fileExists(dir)) {
114 throw new FormatException( 122 throw new FormatException(
115 "Path dependency for package '$name' must refer to a " 123 "Path dependency for package '$name' must refer to a "
116 "directory, not a file. Was '$dir'."); 124 "directory, not a file. Was '$dir'.");
117 } 125 }
118 126
119 throw new FormatException("Could not find package '$name' at '$dir'."); 127 throw new FormatException("Could not find package '$name' at '$dir'.");
120 } 128 }
121 } 129 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698