PBGitRepository: Add method to remove branch

This adds a removeBranch method similar to the addBranch method. It
calls these methods when a branch is created/deleted in the UI, avoiding
the cost of simply calling refresh afterwards.

Signed-off-by: Johannes Gilger <heipei@hackvalue.de>
This commit is contained in:
Johannes Gilger
2009-06-04 11:56:45 +02:00
committed by Pieter de Bie
parent 7b6393570f
commit 64b977e9c8
3 changed files with 16 additions and 2 deletions
+1
View File
@@ -51,6 +51,7 @@ extern NSString* PBGitRepositoryErrorDomain;
- (void) readCurrentBranch;
- (PBGitRevSpecifier*) addBranch: (PBGitRevSpecifier*) rev;
- (BOOL)removeBranch:(PBGitRevSpecifier *)rev;
- (NSString*) parseSymbolicReference:(NSString*) ref;
- (NSString*) parseReference:(NSString*) ref;
+13
View File
@@ -294,6 +294,19 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain";
[self didChangeValueForKey:@"branches"];
return rev;
}
- (BOOL)removeBranch:(PBGitRevSpecifier *)rev
{
for (PBGitRevSpecifier *r in branches) {
if ([rev isEqualTo:r]) {
[self willChangeValueForKey:@"branches"];
[branches removeObject:r];
[self didChangeValueForKey:@"branches"];
return TRUE;
}
}
return FALSE;
}
- (void) readCurrentBranch
{
+2 -2
View File
@@ -49,7 +49,7 @@
NSLog(@"Removing ref failed!");
return;
}
[historyController.repository removeBranch:[[PBGitRevSpecifier alloc] initWithRef:[sender ref]]];
[[sender commit] removeRef:[sender ref]];
[commitController rearrangeObjects];
}
@@ -208,7 +208,7 @@
[errorMessage setStringValue:@"Branch exists"];
return;
}
[historyController.repository addBranch:[[PBGitRevSpecifier alloc] initWithRef:[PBGitRef refFromString:branchName]]];
[self closeSheet:sender];
[commit addRef:[PBGitRef refFromString:branchName]];
[commitController rearrangeObjects];