Chromium Code Reviews

Unified Diff: sdk/lib/_internal/pub/lib/src/command/barback.dart

Issue 216593006: Don't allow overlapping source directories. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Index: sdk/lib/_internal/pub/lib/src/command/barback.dart
diff --git a/sdk/lib/_internal/pub/lib/src/command/barback.dart b/sdk/lib/_internal/pub/lib/src/command/barback.dart
index a36a3720baa69b40145125726876917136728552..72a50ba67325d1447a5ba8e26a3c7198c1327fa5 100644
--- a/sdk/lib/_internal/pub/lib/src/command/barback.dart
+++ b/sdk/lib/_internal/pub/lib/src/command/barback.dart
@@ -112,6 +112,24 @@ abstract class BarbackCommand extends PubCommand {
if (missing.isNotEmpty) {
dataError(_directorySentence(missing, "does", "do", "not exist"));
}
+
+ // Make sure the directories don't overlap.
+ var sources = sourceDirectories.toList();
+ var overlapping = new Set();
+ for (var i = 0; i < sources.length; i++) {
+ for (var j = i + 1; j < sources.length; j++) {
+ if (path.isWithin(sources[i], sources[j]) ||
+ path.isWithin(sources[j], sources[i])) {
+ overlapping.add(sources[i]);
+ overlapping.add(sources[j]);
+ }
+ }
+ }
+
+ if (overlapping.isNotEmpty) {
+ usageError(_directorySentence(overlapping, "cannot", "cannot",
+ "overlap"));
+ }
}
/// Handles "--all" by adding all default source directories that are

Powered by Google App Engine