basic FileMerge support

This commit is contained in:
German Laullon
2011-03-04 13:38:55 -08:00
parent a20e570520
commit 8896dc993c
7 changed files with 58 additions and 18 deletions
+1
View File
@@ -324,6 +324,7 @@
inDiff=TRUE;
NSString *fileName=[self getFileName:line];
[res appendString:[NSString stringWithFormat:@"<table id='%@' class='diff'><thead><tr><td colspan='3'>",fileName]];
[res appendString:[NSString stringWithFormat:@"<div class='filemerge'><a href='' onclick='openFileMerge(\"%@\",\"{SHA}\"); return false;'><img src='GitX://app:/filemerge' width='32' height='32'/><br/>open in<br/>FileMerge</a></div>",fileName]];
[res appendString:[NSString stringWithFormat:@"<p>%@</p>",line]];
}else if(inDiff){
[res appendString:[NSString stringWithFormat:@"<p>%@</p>",line]];
+33 -18
View File
@@ -31,25 +31,40 @@
return;
}
NSString *path=[[url path] substringFromIndex:1];
NSString *v=@"";
if ([[path substringToIndex:5] isEqualToString:@"prev/"]) {
path=[path substringFromIndex:5];
v=@"^";
if ([[url host] isEqualToString:@"app"]) {
NSString *app=[[url path] substringFromIndex:1];
NSString *appPath=[[NSWorkspace sharedWorkspace] fullPathForApplication:app];
NSLog(@"app=%@ appPath=%@",app,appPath);
if(appPath){
NSImage *icon = [[NSWorkspace sharedWorkspace] iconForFile:appPath];
NSLog(@"icon=%@",icon);
[[self client] URLProtocol:self didLoadData:[icon TIFFRepresentation]];
[[self client] URLProtocolDidFinishLoading:self];
}else{
[[self client] URLProtocol:self didFailWithError:[NSError errorWithDomain:@"gitx" code:404 userInfo:nil]];
}
}else {
NSString *path=[[url path] substringFromIndex:1];
NSString *v=@"";
if ([[path substringToIndex:5] isEqualToString:@"prev/"]) {
path=[path substringFromIndex:5];
v=@"^";
}
NSString *specifier = [NSString stringWithFormat:@"%@%@:%@", [url host], v,path];
handle = [repo handleInWorkDirForArguments:[NSArray arrayWithObjects:@"cat-file", @"blob", specifier, nil]];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didFinishFileLoad:) name:NSFileHandleReadToEndOfFileCompletionNotification object:handle];
[handle readToEndOfFileInBackgroundAndNotify];
NSURLResponse *response = [[NSURLResponse alloc] initWithURL:[[self request] URL]
MIMEType:nil
expectedContentLength:-1
textEncodingName:nil];
[[self client] URLProtocol:self
didReceiveResponse:response
cacheStoragePolicy:NSURLCacheStorageNotAllowed];
}
NSString *specifier = [NSString stringWithFormat:@"%@%@:%@", [url host], v,path];
handle = [repo handleInWorkDirForArguments:[NSArray arrayWithObjects:@"cat-file", @"blob", specifier, nil]];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didFinishFileLoad:) name:NSFileHandleReadToEndOfFileCompletionNotification object:handle];
[handle readToEndOfFileInBackgroundAndNotify];
NSURLResponse *response = [[NSURLResponse alloc] initWithURL:[[self request] URL]
MIMEType:nil
expectedContentLength:-1
textEncodingName:nil];
[[self client] URLProtocol:self
didReceiveResponse:response
cacheStoragePolicy:NSURLCacheStorageNotAllowed];
}
- (void) didFinishFileLoad:(NSNotification *)notification
+5
View File
@@ -76,6 +76,11 @@
NSLog(@"Error from webkit: %@", dictionary);
}
- (void)webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame
{
NSLog(@"Message from webkit: %@", message);
}
- (NSURLRequest *)webView:(WebView *)sender
resource:(id)identifier
willSendRequest:(NSURLRequest *)request
+1
View File
@@ -29,6 +29,7 @@
- (NSString *)parseHeader:(NSString *)txt withRefs:(NSString *)badges;
- (NSMutableDictionary *)parseStats:(NSString *)txt;
- (NSString *) someMethodThatReturnsSomeHashForSomeString:(NSString*)concat;
- (void) openFileMerge:(NSString*)file sha:(NSString *)sha;
@property (readonly) NSString* diff;
@end
+7
View File
@@ -224,6 +224,13 @@
[historyController selectCommit:[PBGitSHA shaWithString:sha]];
}
- (void) openFileMerge:(NSString*)file sha:(NSString *)sha
{
NSArray *args=[NSArray arrayWithObjects:@"difftool",@"--no-prompt",@"--tool=opendiff",[NSString stringWithFormat:@"%@^",sha],sha,file,nil];
[historyController.repository handleForArguments:args];
}
- (void) sendKey: (NSString*) key
{
id script = [view windowScriptObject];
+5
View File
@@ -317,4 +317,9 @@ a.showdiff {
-webkit-box-shadow: 5px 5px 5px #ccc;
width: 98%;
margin: auto auto 20px 1%;
}
.filemerge {
float: right;
text-align: center;
}
+6
View File
@@ -2,6 +2,12 @@ var selectCommit = function(a) {
Controller.selectCommit_(a);
}
var openFileMerge = function(file,sha) {
alert(file);
alert(sha);
Controller.openFileMerge_sha_(file,sha);
}
var showImage = function(element, filename)
{
element.outerHTML = '<img src="GitX://' + commit.sha + '/' + filename + '">';