Merge pull request #74 from Uncommon/stash

Show stash contents when selected in the sidebar
This commit is contained in:
German Laullon
2011-06-09 11:53:53 -07:00
13 changed files with 1421 additions and 35 deletions
+1
View File
@@ -7,6 +7,7 @@
//
#import "PBGitRepository.h"
#import "PBPresentable.h"
@protocol PBCommandFactory
+ (NSArray *) commandsForObject:(id<PBPresentable>) object repository:(PBGitRepository *) repository;
+10
View File
@@ -138,6 +138,8 @@
D8FDDA6F114335E8005647F6 /* PBGitSVStageItem.m in Sources */ = {isa = PBXBuildFile; fileRef = D8FDDA67114335E8005647F6 /* PBGitSVStageItem.m */; };
D8FDDA70114335E8005647F6 /* PBGitSVTagItem.m in Sources */ = {isa = PBXBuildFile; fileRef = D8FDDA69114335E8005647F6 /* PBGitSVTagItem.m */; };
D8FDDBF41143F318005647F6 /* AddRemote.png in Resources */ = {isa = PBXBuildFile; fileRef = D8FDDBF31143F318005647F6 /* AddRemote.png */; };
DDB8FE0113998CE2001A9EE2 /* PBStashContentController.m in Sources */ = {isa = PBXBuildFile; fileRef = DDB8FE0013998CE2001A9EE2 /* PBStashContentController.m */; };
DDB8FEC413999C24001A9EE2 /* PBStashContentView.xib in Resources */ = {isa = PBXBuildFile; fileRef = DDB8FEC313999C24001A9EE2 /* PBStashContentView.xib */; };
F50FE0E30E07BE9600854FCD /* PBGitRevisionCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F50FE0E20E07BE9600854FCD /* PBGitRevisionCell.m */; };
F513085B0E0740F2000C8BCD /* PBQLOutlineView.m in Sources */ = {isa = PBXBuildFile; fileRef = F513085A0E0740F2000C8BCD /* PBQLOutlineView.m */; };
F5140DC90E8A8EB20091E9F3 /* RoundedRectangle.m in Sources */ = {isa = PBXBuildFile; fileRef = F5140DC80E8A8EB20091E9F3 /* RoundedRectangle.m */; };
@@ -425,6 +427,9 @@
D8FDDA69114335E8005647F6 /* PBGitSVTagItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitSVTagItem.m; sourceTree = "<group>"; };
D8FDDA7311433634005647F6 /* PBSourceViewItems.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBSourceViewItems.h; sourceTree = "<group>"; };
D8FDDBF31143F318005647F6 /* AddRemote.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = AddRemote.png; path = Images/AddRemote.png; sourceTree = "<group>"; };
DDB8FDFF13998CE2001A9EE2 /* PBStashContentController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBStashContentController.h; sourceTree = "<group>"; };
DDB8FE0013998CE2001A9EE2 /* PBStashContentController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBStashContentController.m; sourceTree = "<group>"; };
DDB8FEC313999C24001A9EE2 /* PBStashContentView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PBStashContentView.xib; sourceTree = "<group>"; };
F50FE0E10E07BE9600854FCD /* PBGitRevisionCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitRevisionCell.h; sourceTree = "<group>"; };
F50FE0E20E07BE9600854FCD /* PBGitRevisionCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitRevisionCell.m; sourceTree = "<group>"; };
F51308590E0740F2000C8BCD /* PBQLOutlineView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBQLOutlineView.h; sourceTree = "<group>"; };
@@ -765,6 +770,7 @@
F5E424100EA3E4D60046E362 /* PBDiffWindow.xib */,
F52BCE020E84208300AA3741 /* PBGitHistoryView.xib */,
F59116E50E843BB50072CCB1 /* PBGitCommitView.xib */,
DDB8FEC313999C24001A9EE2 /* PBStashContentView.xib */,
D85B939210E3D8B4007F3C28 /* PBCreateBranchSheet.xib */,
D889EB3010E6BCBB00F08413 /* PBCreateTagSheet.xib */,
D8C1B77110E875CF009B7F8B /* PBRemoteProgressSheet.xib */,
@@ -939,6 +945,8 @@
77C8280C06725ACE000B614F /* ApplicationController.m */,
93CB42C00EAB7B2200530609 /* PBGitDefaults.h */,
93CB42C10EAB7B2200530609 /* PBGitDefaults.m */,
DDB8FDFF13998CE2001A9EE2 /* PBStashContentController.h */,
DDB8FE0013998CE2001A9EE2 /* PBStashContentController.m */,
F57CC43F0E05E496000472E2 /* PBGitWindowController.h */,
F57CC4400E05E496000472E2 /* PBGitWindowController.m */,
911111F60E594F3F00BF76B4 /* PBRepositoryDocumentController.h */,
@@ -1286,6 +1294,7 @@
316E7202131EE9C600AFBB36 /* list_Template.png in Resources */,
316E7203131EE9C600AFBB36 /* sidebar_Template.png in Resources */,
65D58BC4132D27A8003F7290 /* PBResetSheet.xib in Resources */,
DDB8FEC413999C24001A9EE2 /* PBStashContentView.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1447,6 +1456,7 @@
217FF0BE12A1CB3E00785A65 /* PBRevealWithFinderCommand.m in Sources */,
65D58BC7132D48C2003F7290 /* PBResetSheet.m in Sources */,
31776089133569350025876E /* SearchWebView.m in Sources */,
DDB8FE0113998CE2001A9EE2 /* PBStashContentController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
+1 -1
View File
@@ -33,7 +33,7 @@
IBOutlet PBCommitList* commitList;
IBOutlet NSSplitView *historySplitView;
IBOutlet PBWebHistoryController *webHistoryController;
QLPreviewPanel* previewPanel;
QLPreviewPanel* previewPanel;
IBOutlet PBHistorySearchController *searchController;
IBOutlet GLFileView *fileView;
+2 -2
View File
@@ -94,7 +94,7 @@
[super awakeFromNib];
[fileBrowser setDelegate:self];
[fileBrowser setDelegate:self];
}
- (void)updateKeys
@@ -414,7 +414,7 @@
- (void) updateView
{
[self refresh: nil];
[self refresh: nil];
[self updateKeys];
}
+3 -5
View File
@@ -12,10 +12,6 @@
#import "PBGitConfig.h"
#import "PBGitRefish.h"
#import "PBStashController.h"
#import "PBGitResetController.h"
#import "PBSubmoduleController.h"
extern NSString* PBGitRepositoryErrorDomain;
typedef enum branchFilterTypes {
kGitXAllBranchesFilter = 0,
@@ -42,7 +38,9 @@ static NSString * PBStringFromBranchFilterType(PBGitXBranchFilterType type) {
@class PBGitWindowController;
@class PBGitCommit;
@class NSString;
@class PBGitResetController;
@class PBStashController;
@class PBSubmoduleController;
@interface PBGitRepository : NSDocument {
PBGitHistoryList* revisionList;
+9 -6
View File
@@ -12,14 +12,17 @@
#import "PBGitBinary.h"
#import "NSFileHandleExt.h"
#import "PBEasyPipe.h"
#import "PBGitRef.h"
#import "PBGitRevSpecifier.h"
#import "PBRemoteProgressSheet.h"
#import "PBGitRevList.h"
#import "PBGitDefaults.h"
#import "GitXScriptingConstants.h"
#import "PBEasyPipe.h"
#import "PBGitDefaults.h"
#import "PBGitRef.h"
#import "PBGitResetController.h"
#import "PBGitRevList.h"
#import "PBGitRevSpecifier.h"
#import "PBHistorySearchController.h"
#import "PBRemoteProgressSheet.h"
#import "PBStashController.h"
#import "PBSubmoduleController.h"
#import "PBGitStash.h"
#import "PBGitSubmodule.h"
+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
+13
View File
@@ -23,6 +23,8 @@
#import "PBCommandMenuItem.h"
#import "PBGitStash.h"
#import "PBGitSubmodule.h"
#import "PBSubmoduleController.h"
#import "PBStashContentController.h"
static NSString * const kObservingContextStashes = @"stashesChanged";
static NSString * const kObservingContextSubmodules = @"submodulesChanged";
@@ -42,6 +44,7 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged";
@synthesize sourceListControlsView;
@synthesize historyViewController;
@synthesize commitViewController;
@synthesize stashViewController;
- (id)initWithRepository:(PBGitRepository *)theRepository superController:(PBGitWindowController *)controller
{
@@ -60,6 +63,9 @@ 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];
[stashViewController loadView];
[repository addObserver:self forKeyPath:@"refs" options:0 context:@"updateRefs"];
[repository addObserver:self forKeyPath:@"currentBranch" options:0 context:@"currentBranchChange"];
@@ -83,6 +89,7 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged";
{
[historyViewController closeView];
[commitViewController closeView];
[stashViewController closeView];
[repository removeObserver:self forKeyPath:@"currentBranch"];
[repository removeObserver:self forKeyPath:@"branches"];
@@ -318,6 +325,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];
}
+1
View File
@@ -13,6 +13,7 @@
#import "PBCreateTagSheet.h"
#import "PBGitDefaults.h"
#import "PBDiffWindowController.h"
#import "PBGitResetController.h"
#import "PBArgumentPickerController.h"
+23
View File
@@ -0,0 +1,23 @@
//
// PBStashContentController.h
// GitX
//
// Created by David Catmull on 20-06-11.
// Copyright 2011. All rights reserved.
//
#import "PBViewController.h"
#import "PBWebHistoryController.h"
@class PBGitStash;
@class PBWebStashController;
// Controls the view displaying a stash diff
@interface PBStashContentController : PBViewController {
IBOutlet id webView;
IBOutlet PBWebHistoryController *webController;
}
- (void) showStash:(PBGitStash*)stash;
@end
+29
View File
@@ -0,0 +1,29 @@
//
// PBStashContentController.h
// GitX
//
// Created by David Catmull on 20-06-11.
// Copyright 2011. All rights reserved.
//
#import "PBStashContentController.h"
#import "PBGitDefaults.h"
#import "PBGitStash.h"
@implementation PBStashContentController
- (void) awakeFromNib
{
[webController setRepository:repository];
}
- (void) showStash:(PBGitStash*)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
File diff suppressed because it is too large Load Diff
+19 -21
View File
@@ -39,7 +39,7 @@
- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if ([(NSString *)context isEqualToString: @"ChangedCommit"])
if ([(NSString *)context isEqualToString: @"ChangedCommit"])
[self changeContentTo: historyController.webCommit];
else
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
@@ -84,45 +84,43 @@
return;
NSMutableString *refs=[NSMutableString string];
NSArray *refsA=[historyController.webCommit refs];
NSString *currentRef=[[[historyController repository] headRef] simpleRef];
NSString *style=@"";
int r=0;
for(r=0;r<[refsA count];r++){
PBGitRef *ref=[refsA objectAtIndex:r];
NSMutableString *refs = [NSMutableString string];
NSArray *refsA = [historyController.webCommit refs];
NSString *currentRef = [[[historyController repository] headRef] simpleRef];
NSString *style = @"";
for(PBGitRef *ref in refsA){
if([currentRef isEqualToString:[ref ref]]){
style=[NSString stringWithFormat:@"currentBranch refs %@",[ref type]];
style = [NSString stringWithFormat:@"currentBranch refs %@",[ref type]];
}else{
style=[NSString stringWithFormat:@"refs %@",[ref type]];
style = [NSString stringWithFormat:@"refs %@",[ref type]];
}
[refs appendString:[NSString stringWithFormat:@"<span class='%@'>%@</span>",style,[ref shortName]]];
}
// Header
NSString *header=[self parseHeader:details withRefs:refs];
NSString *header = [self parseHeader:details withRefs:refs];
// File Stats
NSMutableDictionary *stats=[self parseStats:details];
NSMutableDictionary *stats = [self parseStats:details];
// File list
NSString *dt=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--root", @"-r", @"-C90%", @"-M90%", currentSha, nil]];
NSString *fileList=[GLFileView parseDiffTree:dt withStats:stats];
NSString *dt = [repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--root", @"-r", @"-C90%", @"-M90%", currentSha, nil]];
NSString *fileList = [GLFileView parseDiffTree:dt withStats:stats];
// Diffs list
NSString *d=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--root", @"--cc", @"-C90%", @"-M90%", currentSha, nil]];
NSString *diffs=[GLFileView parseDiff:d];
NSString *d = [repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--root", @"--cc", @"-C90%", @"-M90%", currentSha, nil]];
NSString *diffs = [GLFileView parseDiff:d];
NSString *html=[NSString stringWithFormat:@"%@%@<div id='diffs'>%@</div>",header,fileList,diffs];
NSString *html = [NSString stringWithFormat:@"%@%@<div id='diffs'>%@</div>",header,fileList,diffs];
html=[html stringByReplacingOccurrencesOfString:@"{SHA_PREV}" withString:[NSString stringWithFormat:@"%@^",currentSha]];
html=[html stringByReplacingOccurrencesOfString:@"{SHA}" withString:currentSha];
html = [html stringByReplacingOccurrencesOfString:@"{SHA_PREV}" withString:[NSString stringWithFormat:@"%@^",currentSha]];
html = [html stringByReplacingOccurrencesOfString:@"{SHA}" withString:currentSha];
[[view windowScriptObject] callWebScriptMethod:@"showCommit" withArguments:[NSArray arrayWithObject:html]];
#ifdef DEBUG_BUILD
NSString *dom=[(DOMHTMLElement*)[[[view mainFrame] DOMDocument] documentElement] outerHTML];
NSString *tmpFile=@"~/tmp/test2.html";
NSString *dom = [(DOMHTMLElement*)[[[view mainFrame] DOMDocument] documentElement] outerHTML];
NSString *tmpFile = @"~/tmp/test2.html";
[dom writeToFile:[tmpFile stringByExpandingTildeInPath] atomically:true encoding:NSUTF8StringEncoding error:nil];
#endif
}