protected ScmResult executeAccurevCommand( AccuRevScmProviderRepository repository, ScmFileSet fileSet,
CommandParameters parameters )
throws ScmException, AccuRevException
{
AccuRev accuRev = repository.getAccuRev();
File basedir = fileSet.getBasedir();
List<File> elements = fileSet.getFileList();
List<File> defunctElements = accuRev.stat( basedir, elements, AccuRevStat.DEFUNCT );
if ( defunctElements == null )
{
return error( accuRev, "Failed retrieving defunct elements" );
}
List<File> keptElements = accuRev.stat( basedir, elements, AccuRevStat.KEPT );
// Defunct elements are also listed as kept (AccuRev 4.7.1), exclude those here.
if ( keptElements == null )
{
return error( accuRev, "Failed retrieving kept elements" );
}
List<File> modOrAddedElements = new ArrayList<File>();
for ( File file : keptElements )
{
if ( !defunctElements.contains( file ) )
{
modOrAddedElements.add( file );
}
}
List<File> modifiedElements = accuRev.stat( basedir, elements, AccuRevStat.MODIFIED );
if ( modifiedElements == null )
{
return error( accuRev, "Failed retrieving modified elements" );
}
modOrAddedElements.addAll( modifiedElements );
CategorisedElements catElems = accuRev.statBackingStream( basedir, modOrAddedElements );
if ( catElems == null )
{
return error( accuRev, "Failed stat backing stream to split modified and added elements" );
}
modifiedElements = catElems.getMemberElements();
List<File> addedElements;
if ( AccuRevCapability.STAT_ADDED_NOT_PROMOTED_BUG.isSupported( accuRev.getClientVersion() ) )
{
modOrAddedElements.removeAll( modifiedElements );
addedElements = modOrAddedElements;
}
else
{
addedElements = catElems.getNonMemberElements();
}
List<File> missingElements = accuRev.stat( basedir, elements, AccuRevStat.MISSING );
if ( missingElements == null )
{
return error( accuRev, "Failed retrieving missing elements" );
}
List<File> externalElements = accuRev.stat( basedir, elements, AccuRevStat.EXTERNAL );
if ( externalElements == null )
{
return error( accuRev, "Failed retrieving external elements" );
}
List<ScmFile> resultFiles = getScmFiles( defunctElements, ScmFileStatus.DELETED );
resultFiles.addAll( getScmFiles( modifiedElements, ScmFileStatus.MODIFIED ) );
resultFiles.addAll( getScmFiles( addedElements, ScmFileStatus.ADDED ) );
resultFiles.addAll( getScmFiles( missingElements, ScmFileStatus.MISSING ) );
resultFiles.addAll( getScmFiles( externalElements, ScmFileStatus.UNKNOWN ) );
return new StatusScmResult( accuRev.getCommandLines(), resultFiles );
}