[SVN] Making the commit window work with external diff'ers.

Luke Daley ld at ldaley.com
Fri Apr 3 03:46:20 UTC 2009


The commit window app assumes that your diff invocation will return  
the diff. This is not always the case. If you are using Changes.app  
your invocation of svn diff doesn't actually return the diff.

The commit window app needs to be smarter in that it should try to  
send anything to mate if the diff command didn't return any output.  
The offending method in CommitWindowCommandLine.m is…

- (IBAction) doubleClickRowInTable:(id)sender
{
	if( fDiffCommand != nil )
	{
		static NSString *	sCommandAbsolutePath = nil;

		NSMutableArray *	arguments	= [[fDiffCommand  
componentsSeparatedByString:@","] mutableCopy];
		NSString *			filePath	= [[[[fFilesController arrangedObjects]  
objectAtIndex:[sender selectedRow]] objectForKey:@"path"]  
stringByStandardizingPath];
		NSData *			diffData;
		NSString *			errorText;
		int					exitStatus;
		
		// Resolve the command to an absolute path (only do this once per  
launch)
		if(sCommandAbsolutePath == nil)
		{
			sCommandAbsolutePath = [[self absolutePathForPath:[arguments  
objectAtIndex:0]] retain];
		}
		[arguments replaceObjectAtIndex:0 withObject:sCommandAbsolutePath];

		// Run the diff
		[arguments addObject:filePath];
		exitStatus = [NSTask executeTaskWithArguments:arguments
			    					input:nil
			                        outputData:&diffData
			                        errorString:&errorText];
		[self checkExitStatus:exitStatus forCommand:arguments  
errorText:errorText];

		// Success, send the diff to TextMate
		arguments = [NSArray arrayWithObjects:[NSString  
stringWithFormat:@"%s/bin/mate", getenv("TM_SUPPORT_PATH")], @"-a",  
nil];
		
		exitStatus = [NSTask executeTaskWithArguments:arguments
			    					input:diffData
			                        outputData:nil
			                        errorString:&errorText];
		[self checkExitStatus:exitStatus forCommand:arguments  
errorText:errorText];
	}
}

Ideally, it would be nice to have TM pop up a dialog. Which probably  
means we need to invoke tm_dialog here.

I'll try and add this in, but can someone tell me how I would go about  
building this damn thing? There is no xcode project or build script of  
any kind to my eyes.


More information about the textmate-dev mailing list