This repository has been archived by the owner on Jul 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CORevisionInfo.m
95 lines (82 loc) · 2.27 KB
/
CORevisionInfo.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#import "CORevisionInfo.h"
#import <EtoileFoundation/Macros.h>
@implementation CORevisionInfo
NSString *kCORevisionID = @"CORevisionID";
NSString *kCORevisionParentID = @"CORevisionParentID";
NSString *kCORevisionMetadata = @"CORevisionMetadata";
- (id) initWithRevisionID: (CORevisionID *)revisionId
parentRevisionID: (CORevisionID *)parentRevisionId
metadata: (NSDictionary *)metadata
{
NSParameterAssert(revisionId != nil);
SUPERINIT;
ASSIGN(revisionID_, revisionId);
ASSIGN(parentRevisionID_, parentRevisionId);
ASSIGN(metadata_, metadata);
return self;
}
- (void) dealloc
{
[revisionID_ release];
[parentRevisionID_ release];
[metadata_ release];
[super dealloc];
}
- (CORevisionID *)revisionID
{
return revisionID_;
}
- (CORevisionID *)parentRevisionID
{
return parentRevisionID_;
}
- (NSDictionary *)metadata
{
return metadata_;
}
- (BOOL) isEqual:(id)object
{
if ([object isKindOfClass: [CORevisionInfo class]])
{
return [((CORevisionInfo *)object)->revisionID_ isEqual: revisionID_]
&& [((CORevisionInfo *)object)->parentRevisionID_ isEqual: parentRevisionID_];
}
return NO;
}
- (NSUInteger) hash
{
return [revisionID_ hash] ^ 15497645834521126867ULL;
}
- (id) plist
{
NSMutableDictionary *d = [NSMutableDictionary dictionary];
[d setObject: [revisionID_ plist] forKey: kCORevisionID];
if (parentRevisionID_ != nil)
{
[d setObject: [parentRevisionID_ plist] forKey: kCORevisionParentID];
}
if (metadata_ != nil)
{
[d setObject: metadata_ forKey: kCORevisionMetadata];
}
return d;
}
+ (CORevisionInfo *) revisionWithPlist: (id)plist
{
return [[[self alloc] initWithRevisionID: [plist objectForKey:kCORevisionID]
parentRevisionID: [plist objectForKey: kCORevisionParentID]
metadata: [plist objectForKey: kCORevisionMetadata]] autorelease];
}
- (id) copyWithZone:(NSZone *)zone
{
return [self retain];
}
- (NSString *)description
{
if (parentRevisionID_ != nil)
{
return [NSString stringWithFormat: @"(Revision %@, Parent %@)", revisionID_, parentRevisionID_];
}
return [NSString stringWithFormat: @"(Revision %@)", revisionID_];
}
@end