From 1700c86669723045bf7abd177ca519f47656e995 Mon Sep 17 00:00:00 2001 From: Joe Wreschnig Date: Sun, 3 Mar 2013 13:57:46 +0100 Subject: [PATCH] Implement equality checks for Targets. Don't consider equal targets as conflicting when importing. --- ConfigsController.m | 3 ++- Target.m | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ConfigsController.m b/ConfigsController.m index 0c32b8b..fb50bc3 100644 --- a/ConfigsController.m +++ b/ConfigsController.m @@ -200,7 +200,8 @@ BOOL conflict; Config *mergeInto = self[cfg.name]; for (id key in cfg.entries) { - if (mergeInto.entries[key]) { + if (mergeInto.entries[key] + && ![mergeInto.entries[key] isEqual:cfg.entries[key]]) { conflict = YES; break; } diff --git a/Target.m b/Target.m index 700a151..493f94a 100644 --- a/Target.m +++ b/Target.m @@ -28,6 +28,15 @@ return nil; } +- (BOOL)isEqual:(id)object { + return [object isKindOfClass:Target.class] + && [[self serialize] isEqual:[object serialize]]; +} + +- (NSUInteger)hash { + return [[self serialize] hash]; +} + + (Target *)targetDeserialize:(NSDictionary *)serialization withConfigs:(NSArray *)configs { // Don't crash loading old configs (but don't load them either). -- 2.30.2