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
/
Copy pathCOEditSetCurrentBranch.m
64 lines (51 loc) · 1.94 KB
/
COEditSetCurrentBranch.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
#import "COEditSetCurrentBranch.h"
#import <EtoileFoundation/Macros.h>
@implementation COEditSetCurrentBranch : COEdit
static NSString *kCOOldBranchUUID = @"COOldBranchUUID";
static NSString *kCONewBranchUUID = @"CONewBranchUUID";
- (id) initWithOldBranchUUID: (ETUUID*)aOldBranchUUID
newBranchUUID: (ETUUID*)aNewBranchUUID
UUID: (ETUUID*)aUUID
date: (NSDate*)aDate
displayName: (NSString*)aName
{
NILARG_EXCEPTION_TEST(aOldBranchUUID);
NILARG_EXCEPTION_TEST(aNewBranchUUID);
self = [super initWithUUID: aUUID date: aDate displayName: aName];
ASSIGN(oldBranch_, aOldBranchUUID);
ASSIGN(newBranch_, aNewBranchUUID);
return self;
}
- (id) initWithPlist: (id)plist
{
self = [super initWithPlist: plist];
ASSIGN(oldBranch_, [ETUUID UUIDWithString: [plist objectForKey: kCOOldBranchUUID]]);
ASSIGN(newBranch_, [ETUUID UUIDWithString: [plist objectForKey: kCONewBranchUUID]]);
return self;
}
- (id)plist
{
NSMutableDictionary *result = [NSMutableDictionary dictionary];
[result addEntriesFromDictionary: [super plist]];
[result setObject: [oldBranch_ stringValue] forKey: kCOOldBranchUUID];
[result setObject: [newBranch_ stringValue] forKey: kCONewBranchUUID];
[result setObject: kCOEditSetCurrentBranch forKey: kCOUndoAction];
return result;
}
- (COEdit *) inverseForApplicationTo: (COPersistentRootInfo *)aProot
{
return [[[[self class] alloc] initWithOldBranchUUID: newBranch_
newBranchUUID: oldBranch_
UUID: uuid_
date: date_
displayName: displayName_] autorelease];
}
- (void) applyToPersistentRoot: (COPersistentRootInfo *)aProot
{
[aProot setCurrentBranchUUID: newBranch_];
}
+ (BOOL) isUndoable
{
return YES;
}
@end