plug the stuff in, not working yet

This commit is contained in:
David Catmull
2011-06-03 17:38:05 -06:00
parent 94c08dd5bc
commit e1836bb02a
4 changed files with 49 additions and 9 deletions
+3
View File
@@ -12,6 +12,7 @@
@class PBSourceViewItem;
@class PBGitHistoryController;
@class PBGitCommitController;
@class PBStashContentController;
@interface PBGitSidebarController : PBViewController PROTOCOL_10_6(NSOutlineViewDelegate, NSMenuDelegate){
IBOutlet NSWindow *window;
@@ -33,6 +34,7 @@
PBGitHistoryController *historyViewController;
PBGitCommitController *commitViewController;
PBStashContentController *stashViewController;
}
- (void) selectStage;
@@ -54,5 +56,6 @@
@property(readonly) NSView *sourceListControlsView;
@property(readonly) PBGitHistoryController *historyViewController;
@property(readonly) PBGitCommitController *commitViewController;
@property(readonly) PBStashContentController *stashViewController;
@end
+9
View File
@@ -24,6 +24,7 @@
#import "PBGitStash.h"
#import "PBGitSubmodule.h"
#import "PBSubmoduleController.h"
#import "PBStashContentController.h"
static NSString * const kObservingContextStashes = @"stashesChanged";
static NSString * const kObservingContextSubmodules = @"submodulesChanged";
@@ -43,6 +44,7 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged";
@synthesize sourceListControlsView;
@synthesize historyViewController;
@synthesize commitViewController;
@synthesize stashViewController;
- (id)initWithRepository:(PBGitRepository *)theRepository superController:(PBGitWindowController *)controller
{
@@ -61,6 +63,7 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged";
historyViewController = [[PBGitHistoryController alloc] initWithRepository:repository superController:superController];
commitViewController = [[PBGitCommitController alloc] initWithRepository:repository superController:superController];
stashViewController = [[PBStashContentController alloc] initWithRepository:repository superController:superController];
[repository addObserver:self forKeyPath:@"refs" options:0 context:@"updateRefs"];
[repository addObserver:self forKeyPath:@"currentBranch" options:0 context:@"currentBranchChange"];
@@ -319,6 +322,12 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged";
[PBGitDefaults setShowStageView:YES];
}
if ([item parent] == stashes) {
[superController changeContentController:stashViewController];
[PBGitDefaults setShowStageView:NO];
[stashViewController showStash:(PBGitStash*)[(PBGitMenuItem*)item sourceObject]];
}
[self updateActionMenu];
[self updateRemoteControls];
}
+3 -8
View File
@@ -7,7 +7,7 @@
//
#import "PBViewController.h"
#import "PBWebController.h"
#import "PBWebHistoryController.h"
@class PBGitStash;
@class PBWebStashController;
@@ -22,13 +22,8 @@
@end
@interface PBWebStashController : PBWebController {
PBGitStash* currentStash;
NSString* diff;
// TODO: This class may not be needed
@interface PBWebStashController : PBWebHistoryController {
}
- (void) changeContentTo:(PBGitStash*)stash;
@property (readonly) NSString* diff;
@end
+34 -1
View File
@@ -7,17 +7,50 @@
//
#import "PBStashContentController.h"
#import "PBGitDefaults.h"
#import "PBGitStash.h"
@implementation PBStashContentController
- (void) awakeFromNib
{
[webController setRepository:repository];
}
- (void) showStash:(PBGitStash*)stash
{
[webController changeContentTo:stash];
NSString *stashRef = [NSString stringWithFormat:@"refs/%@", [stash name]];
NSString *stashSha = [repository shaForRef:[PBGitRef refFromString:stashRef]];
PBGitCommit *commit = [PBGitCommit commitWithRepository:repository andSha:stashSha];
[webController changeContentTo:commit];
}
@end
@implementation PBWebStashController
/*
- (void) changeContentTo:(PBGitStash*)stash
{
if (stash == nil || !finishedLoading)
return;
currentStash = stash;
// TODO: get the stash's SHA and put it in currentSha
NSString *stashRef = [NSString stringWithFormat:@"refs/%@", [stash name]];
NSMutableArray *taskArguments = [NSMutableArray arrayWithObjects:@"show", @"--numstat", @"--summary", @"--pretty=raw", stashRef, nil];
if (![PBGitDefaults showWhitespaceDifferences])
[taskArguments insertObject:@"-w" atIndex:1];
NSFileHandle *handle = [repository handleForArguments:taskArguments];
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc removeObserver:self name:NSFileHandleReadToEndOfFileCompletionNotification object:nil];
[nc addObserver:self selector:@selector(commitDetailsLoaded:) name:NSFileHandleReadToEndOfFileCompletionNotification object:handle];
[handle readToEndOfFileInBackgroundAndNotify];
}
*/
@end