getLogger().info( "Attempting to display blame results for file: " + filename );
if ( null == filename || filename.length() == 0 )
{
throw new ScmException( "A single filename is required to execute the blame command!" );
}
BlameScmResult result;
IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
APISession api = iRepo.getAPISession();
// Since the si annotate command is not completely API ready, we will use the CLI for this command
Commandline shell = new Commandline();
shell.setWorkingDirectory( workingDirectory.getBasedir() );
shell.setExecutable( "si" );
shell.createArg().setValue( "annotate" );
shell.createArg().setValue( "--hostname=" + api.getHostName() );
shell.createArg().setValue( "--port=" + api.getPort() );
shell.createArg().setValue( "--user=" + api.getUserName() );
shell.createArg().setValue( "--fields=date,revision,author" );
shell.createArg().setValue( '"' + filename + '"' );
IntegrityBlameConsumer shellConsumer = new IntegrityBlameConsumer( getLogger() );
try
{
getLogger().debug( "Executing: " + shell.getCommandline() );
int exitCode = CommandLineUtils.executeCommandLine( shell, shellConsumer,
new CommandLineUtils.StringStreamConsumer() );
boolean success = ( exitCode == 128 ? false : true );
ScmResult scmResult =
new ScmResult( shell.getCommandline().toString(), "", "Exit Code: " + exitCode, success );
return new BlameScmResult( shellConsumer.getBlameList(), scmResult );
}
catch ( CommandLineException cle )
{
getLogger().error( "Command Line Exception: " + cle.getMessage() );
result = new BlameScmResult( shell.getCommandline().toString(), cle.getMessage(), "", false );
}
return result;
}