@Override
protected List<File> extractSource( AccuRevScmProviderRepository repository, File basedir, AccuRevVersion version )
throws AccuRevException
{
AccuRev accuRev = repository.getAccuRev();
AccuRevInfo info = accuRev.info( basedir );
String basisStream = version.getBasisStream();
String transactionId = version.getTimeSpec();
if ( !AccuRevVersion.isNow( transactionId )
&& !AccuRevCapability.POPULATE_TO_TRANSACTION.isSupported( accuRev.getClientVersion() ) )
{
getLogger().warn(
String.format( "Ignoring transaction id %s, Export can only extract current sources",
transactionId ) );
transactionId = "now";
} else {
//We might be heading to a transaction id that is not yet available on a replica
accuRev.syncReplica();
}
boolean removedWorkspace = false;
// We'll do a pop -V.
if ( info.isWorkSpace() )
{
String stat = accuRev.stat( basedir );
if ( stat != null )
{
throw new AccuRevException(
String.format(
"Cannot populate %s, as it is a non-ignored subdirectory of workspace %s rooted at %s.",
basedir.getAbsolutePath(), info.getWorkSpace(),
info.getTop() ) );
}
// ok, the subdirectory must be ignored. temporarily remove the workspace.
removedWorkspace = accuRev.rmws( info.getWorkSpace() );
}
try
{
return accuRev.popExternal(
basedir,
basisStream,
transactionId,
Collections.singletonList( new File( repository.getDepotRelativeProjectPath() ) ) );
}
finally
{
if ( removedWorkspace )
{
accuRev.reactivate( info.getWorkSpace() );
}
}
}