Search in sources :

Example 6 with AccuRevException

use of org.apache.maven.scm.provider.accurev.AccuRevException in project maven-scm by apache.

the class AccuRevExportCommand method extractSource.

@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;
    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 {
        File path = new File(repository.getDepotRelativeProjectPath());
        return accuRev.popExternal(basedir, basisStream, transactionId, Collections.singletonList(path));
    } finally {
        if (removedWorkspace) {
            accuRev.reactivate(info.getWorkSpace());
        }
    }
}
Also used : AccuRev(org.apache.maven.scm.provider.accurev.AccuRev) AccuRevException(org.apache.maven.scm.provider.accurev.AccuRevException) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) AccuRevInfo(org.apache.maven.scm.provider.accurev.AccuRevInfo)

Aggregations

AccuRevException (org.apache.maven.scm.provider.accurev.AccuRevException)6 AccuRev (org.apache.maven.scm.provider.accurev.AccuRev)4 File (java.io.File)3 AccuRevInfo (org.apache.maven.scm.provider.accurev.AccuRevInfo)3 ScmException (org.apache.maven.scm.ScmException)2 ScmFile (org.apache.maven.scm.ScmFile)2 ScmVersion (org.apache.maven.scm.ScmVersion)2 AccuRevVersion (org.apache.maven.scm.provider.accurev.AccuRevVersion)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 ScmBranch (org.apache.maven.scm.ScmBranch)1 ScmRevision (org.apache.maven.scm.ScmRevision)1 ChangeLogScmResult (org.apache.maven.scm.command.changelog.ChangeLogScmResult)1 ChangeLogSet (org.apache.maven.scm.command.changelog.ChangeLogSet)1 AccuRevScmProviderRepository (org.apache.maven.scm.provider.accurev.AccuRevScmProviderRepository)1 FileDifference (org.apache.maven.scm.provider.accurev.FileDifference)1 Stream (org.apache.maven.scm.provider.accurev.Stream)1 Transaction (org.apache.maven.scm.provider.accurev.Transaction)1 CommandLineException (org.codehaus.plexus.util.cli.CommandLineException)1