(inital) display if remotes need a fetch

This commit is contained in:
German Laullon
2011-01-07 00:37:29 -08:00
parent 0253054fe5
commit 0151598af0
4 changed files with 27 additions and 6 deletions
+3 -1
View File
@@ -11,9 +11,11 @@
@interface PBGitSVRemoteItem : PBSourceViewItem {
BOOL alert;
}
@property (assign) BOOL alert;
+ (id)remoteItemWithTitle:(NSString *)title;
@end
+1
View File
@@ -12,6 +12,7 @@
@implementation PBGitSVRemoteItem
@synthesize alert;
+ (id)remoteItemWithTitle:(NSString *)title
{
+2
View File
@@ -40,6 +40,8 @@
- (void)setHistorySearch:(NSString *)searchString mode:(NSInteger)mode;
-(bool)remoteNeedFetch:(NSString *)remote;
@property(readonly) NSMutableArray *items;
@property(readonly) NSView *sourceListControlsView;
@property(readonly) PBGitHistoryController *historyViewController;
+21 -5
View File
@@ -51,6 +51,7 @@
historyViewController = [[PBGitHistoryController alloc] initWithRepository:repository superController:superController];
commitViewController = [[PBGitCommitController alloc] initWithRepository:repository superController:superController];
[repository addObserver:self forKeyPath:@"refs" options:0 context:@"updateRefs"];
[repository addObserver:self forKeyPath:@"currentBranch" options:0 context:@"currentBranchChange"];
[repository addObserver:self forKeyPath:@"branches" options:(NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew) context:@"branchesModified"];
@@ -79,9 +80,7 @@
[sourceView reloadData];
[self selectCurrentBranch];
return;
}
if ([@"branchesModified" isEqualToString:context]) {
}else if ([@"branchesModified" isEqualToString:context]) {
NSInteger changeKind = [(NSNumber *)[change objectForKey:NSKeyValueChangeKindKey] intValue];
if (changeKind == NSKeyValueChangeInsertion) {
@@ -97,10 +96,22 @@
for (PBGitRevSpecifier *rev in removedRevSpecs)
[self removeRevSpec:rev];
}
return;
}else if ([@"updateRefs" isEqualToString:context]) {
for(PBGitSVRemoteItem* remote in [remotes children]){
NSLog(@"remote.title=%@",[remote title]);
[remote setAlert:[self remoteNeedFetch:[remote title]]];
}
}else{
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
}
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
-(bool)remoteNeedFetch:(NSString *)remote
{
int ret;
NSArray *args = [NSArray arrayWithObjects:@"fetch", @"--dry-run", remote, nil];
NSString *o = [repository outputForArguments:args retValue:&ret];
return ((ret==0) && ([o length]!=0));
}
- (PBSourceViewItem *) selectedItem
@@ -231,6 +242,11 @@
cell.behind=nil;
cell.ahead=nil;
}
if([item isKindOfClass:[PBGitSVRemoteItem class]]){
NSLog(@"title: %@",[item title]);
cell.isCheckedOut=[item alert];
}
[cell setImage:[item icon]];
}