throws ScmException
{
try
{
//Build commandline
Commandline cmd = buildCmd( workingDir, cmdAndArgs );
if ( logger.isInfoEnabled() )
{
logger.info( "EXECUTING: " + maskPassword( cmd ) );
}
//Execute command
int exitCode = executeCmd( consumer, cmd );
//Return result
List<Integer> exitCodes = DEFAULT_EXIT_CODES;
if ( EXIT_CODE_MAP.containsKey( cmdAndArgs[0] ) )
{
exitCodes = EXIT_CODE_MAP.get( cmdAndArgs[0] );
}
boolean success = exitCodes.contains( Integer.valueOf( exitCode ) );
//On failure (and not due to exceptions) - run diagnostics
String providerMsg = "Execution of hg command succeded";
if ( !success )
{
HgConfig config = new HgConfig( workingDir );
providerMsg =
"\nEXECUTION FAILED" + "\n Execution of cmd : " + cmdAndArgs[0] + " failed with exit code: "
+ exitCode + "." + "\n Working directory was: " + "\n " + workingDir.getAbsolutePath()
+ config.toString( workingDir ) + "\n";
if ( logger.isErrorEnabled() )
{
logger.error( providerMsg );
}
}
return new ScmResult( cmd.toString(), providerMsg, consumer.getStdErr(), success );
}
catch ( ScmException se )
{
String msg =
"EXECUTION FAILED" + "\n Execution failed before invoking the Hg command. Last exception:" + "\n "