Index: sdk/lib/_internal/pub/lib/src/source_registry.dart |
diff --git a/sdk/lib/_internal/pub/lib/src/source_registry.dart b/sdk/lib/_internal/pub/lib/src/source_registry.dart |
index ffac4f8d7d8ac0bf43ba1b94b1b5ce005e36bbcc..d46ae93ae77299674c4b8004105cf8bf41bb7bf5 100644 |
--- a/sdk/lib/_internal/pub/lib/src/source_registry.dart |
+++ b/sdk/lib/_internal/pub/lib/src/source_registry.dart |
@@ -6,6 +6,7 @@ library pub.source_registry; |
import 'dart:collection'; |
+import 'package.dart'; |
import 'source.dart'; |
import 'source/unknown.dart'; |
@@ -24,6 +25,22 @@ class SourceRegistry extends IterableBase<Source> { |
return sources.iterator; |
} |
+ /// Returns whether [id1] and [id2] refer to the same package, including |
+ /// validating that their descriptions are equivalent. |
+ bool idsEqual(PackageId id1, PackageId id2) { |
+ if (id1 != id2) return false; |
+ if (id1 == null && id2 == null) return true; |
+ return idDescriptionsEqual(id1, id2); |
+ } |
+ |
+ /// Returns whether [id1] and [id2] have the same source and description. |
+ /// |
+ /// This doesn't check whether the name or versions are equal. |
+ bool idDescriptionsEqual(PackageId id1, PackageId id2) { |
+ if (id1.source != id2.source) return false; |
+ return this[id1.source].descriptionsEqual(id1.description, id2.description); |
+ } |
+ |
/// Sets the default source. |
/// |
/// This takes a string, which must be the name of a registered source. |