This repository was 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
Expand file tree
/
Copy pathCOEditSetCurrentVersionForBranch.m
More file actions
70 lines (59 loc) · 2.3 KB
/
COEditSetCurrentVersionForBranch.m
File metadata and controls
70 lines (59 loc) · 2.3 KB
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
#import "COEditSetCurrentVersionForBranch.h"
#import <EtoileFoundation/Macros.h>
#import "COSQLiteStore.h"
@implementation COEditSetCurrentVersionForBranch : COEdit
static NSString *kCOBranchUUID = @"COBranchUUID";
static NSString *kCOOldVersionToken = @"COOldVersionToken";
static NSString *kCONewVersionToken = @"CONewVersionToken";
- (id) initWithBranch: (ETUUID *)aBranch
oldToken: (CORevisionID *)oldToken
newToken: (CORevisionID *)newToken
UUID: (ETUUID*)aUUID
date: (NSDate*)aDate
displayName: (NSString*)aName
{
NILARG_EXCEPTION_TEST(aBranch);
NILARG_EXCEPTION_TEST(oldToken);
NILARG_EXCEPTION_TEST(newToken);
self = [super initWithUUID: aUUID date: aDate displayName: aName];
ASSIGN(branch_, aBranch);
ASSIGN(oldToken_, oldToken);
ASSIGN(newToken_, newToken);
return self;
}
- (id) initWithPlist: (id)plist
{
self = [super initWithPlist: plist];
ASSIGN(branch_, [ETUUID UUIDWithString: [plist objectForKey: kCOBranchUUID]]);
ASSIGN(oldToken_, [CORevisionID revisionIDWithPlist: [plist objectForKey: kCOOldVersionToken]]);
ASSIGN(newToken_, [CORevisionID revisionIDWithPlist: [plist objectForKey: kCONewVersionToken]]);
return self;
}
- (id)plist
{
NSMutableDictionary *result = [NSMutableDictionary dictionary];
[result addEntriesFromDictionary: [super plist]];
[result setObject: [branch_ stringValue] forKey: kCOBranchUUID];
[result setObject: [oldToken_ plist] forKey: kCOOldVersionToken];
[result setObject: [newToken_ plist] forKey: kCONewVersionToken];
[result setObject: kCOEditSetCurrentVersionForBranch forKey: kCOUndoAction];
return result;
}
- (COEdit *) inverseForApplicationTo: (COPersistentRootInfo *)aProot
{
return [[[[self class] alloc] initWithBranch: branch_
oldToken: newToken_
newToken: oldToken_
UUID: uuid_
date: date_
displayName: displayName_] autorelease];
}
- (void) applyToPersistentRoot: (COPersistentRootInfo *)aProot
{
[[aProot branchInfoForUUID: branch_] setCurrentRevisionID: newToken_];
}
+ (BOOL) isUndoable
{
return YES;
}
@end