@Override
public DiffScmResult executeDiffCommand( ScmProviderRepository repository, ScmFileSet fileSet,
ScmVersion startRevision, ScmVersion endRevision )
throws ScmException
{
DiffScmResult result;
IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
APISession api = iRepo.getAPISession();
getLogger().info( "Showing differences bettween local files in " + fileSet.getBasedir().getAbsolutePath()
+ " and server project " + iRepo.getConfigruationPath() );
// Since the si diff command is not completely API ready, we will use the CLI for this command
Commandline shell = new Commandline();
shell.setWorkingDirectory( fileSet.getBasedir() );
shell.setExecutable( "si" );
shell.createArg().setValue( "diff" );
shell.createArg().setValue( "--hostname=" + api.getHostName() );
shell.createArg().setValue( "--port=" + api.getPort() );
shell.createArg().setValue( "--user=" + api.getUserName() );
shell.createArg().setValue( "-R" );
shell.createArg().setValue( "--filter=changed:all" );
shell.createArg().setValue( "--filter=format:text" );
IntegrityDiffConsumer shellConsumer = new IntegrityDiffConsumer( 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 );
// Since we can't really parse the differences output, we'll just have to go by the command output
// Returning a DiffScmResult(List changedFiles, Map differences, String patch, ScmResult result) to avoid an NPE
// in org.codehaus.plexus.util.FileUtils.fileWrite(FileUtils.java:426)
return new DiffScmResult( new ArrayList<ScmFile>(), new HashMap<String, CharSequence>(), "", scmResult );
}
catch ( CommandLineException cle )
{
getLogger().error( "Command Line Exception: " + cle.getMessage() );
result = new DiffScmResult( shell.getCommandline().toString(), cle.getMessage(), "", false );
}
return result;
}