Search in sources :

Example 6 with VssScmProviderRepository

use of org.apache.maven.scm.provider.vss.repository.VssScmProviderRepository in project maven-scm by apache.

the class VssCheckInCommand method executeCheckInCommand.

/**
 * (non-Javadoc)
 *
 * @see org.apache.maven.scm.command.checkin.AbstractCheckInCommand# executeCheckInCommand
 * (org.apache.maven.scm.provider.ScmProviderRepository, org.apache.maven.scm.ScmFileSet,
 * java.lang.String, org.apache.maven.scm.ScmVersion)
 */
protected CheckInScmResult executeCheckInCommand(ScmProviderRepository repository, ScmFileSet fileSet, String message, ScmVersion scmVersion) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing checkin command...");
    }
    VssScmProviderRepository repo = (VssScmProviderRepository) repository;
    List<Commandline> commandLines = buildCmdLine(repo, fileSet, scmVersion);
    VssCheckInConsumer consumer = new VssCheckInConsumer(repo, getLogger());
    // TODO handle deleted files from VSS
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    int exitCode;
    StringBuilder sb = new StringBuilder();
    for (Commandline cl : commandLines) {
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Executing: " + cl.getWorkingDirectory().getAbsolutePath() + ">>" + cl.toString());
        }
        exitCode = VssCommandLineUtils.executeCommandline(cl, consumer, stderr, getLogger());
        if (exitCode != 0) {
            String error = stderr.getOutput();
            if (getLogger().isDebugEnabled()) {
                getLogger().debug("VSS returns error: [" + error + "] return code: [" + exitCode + "]");
            }
            if (error.indexOf("A writable copy of") < 0) {
                return new CheckInScmResult(cl.toString(), "The vss command failed.", error, false);
            }
            // print out the writable copy for manual handling
            if (getLogger().isWarnEnabled()) {
                getLogger().warn(error);
            }
        }
    }
    return new CheckInScmResult(sb.toString(), new ArrayList<ScmFile>());
}
Also used : Commandline(org.codehaus.plexus.util.cli.Commandline) VssScmProviderRepository(org.apache.maven.scm.provider.vss.repository.VssScmProviderRepository) CheckInScmResult(org.apache.maven.scm.command.checkin.CheckInScmResult) ScmFile(org.apache.maven.scm.ScmFile) VssCommandLineUtils(org.apache.maven.scm.provider.vss.commands.VssCommandLineUtils) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils)

Example 7 with VssScmProviderRepository

use of org.apache.maven.scm.provider.vss.repository.VssScmProviderRepository in project maven-scm by apache.

the class VssEditCommand method executeEditCommand.

/**
 * {@inheritDoc}
 */
protected ScmResult executeEditCommand(ScmProviderRepository repository, ScmFileSet fileSet) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing checkout command...");
    }
    VssScmProviderRepository repo = (VssScmProviderRepository) repository;
    List<Commandline> commandLines = buildCmdLine(repo, fileSet);
    VssEditConsumer consumer = new VssEditConsumer(repo, getLogger());
    // TODO handle deleted files from VSS
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    int exitCode;
    StringBuilder sb = new StringBuilder();
    List<ScmFile> updatedFiles = new ArrayList<ScmFile>();
    for (Commandline cl : commandLines) {
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Executing: " + cl.getWorkingDirectory().getAbsolutePath() + ">>" + cl.toString());
        }
        exitCode = VssCommandLineUtils.executeCommandline(cl, consumer, stderr, getLogger());
        if (exitCode != 0) {
            String error = stderr.getOutput();
            if (getLogger().isDebugEnabled()) {
                getLogger().debug("VSS returns error: [" + error + "] return code: [" + exitCode + "]");
            }
            if (error.indexOf("A writable copy of") < 0) {
                return new EditScmResult(cl.toString(), "The vss command failed.", error, false);
            }
            // print out the writable copy for manual handling
            if (getLogger().isWarnEnabled()) {
                getLogger().warn(error);
            }
            break;
        }
        sb.append(cl.toString() + '\n');
        updatedFiles.addAll(consumer.getUpdatedFiles());
    }
    return new EditScmResult(sb.toString(), updatedFiles);
}
Also used : Commandline(org.codehaus.plexus.util.cli.Commandline) VssScmProviderRepository(org.apache.maven.scm.provider.vss.repository.VssScmProviderRepository) ArrayList(java.util.ArrayList) ScmFile(org.apache.maven.scm.ScmFile) VssCommandLineUtils(org.apache.maven.scm.provider.vss.commands.VssCommandLineUtils) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) EditScmResult(org.apache.maven.scm.command.edit.EditScmResult)

Example 8 with VssScmProviderRepository

use of org.apache.maven.scm.provider.vss.repository.VssScmProviderRepository in project maven-scm by apache.

the class VssUpdateCommand method executeUpdateCommand.

// TODO handle deleted files from VSS
/**
 * {@inheritDoc}
 */
protected UpdateScmResult executeUpdateCommand(ScmProviderRepository repository, ScmFileSet fileSet, ScmVersion version) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing update command...");
    }
    VssScmProviderRepository repo = (VssScmProviderRepository) repository;
    Commandline cl = buildCmdLine(repo, fileSet, version);
    VssUpdateConsumer consumer = new VssUpdateConsumer(repo, getLogger());
    // TODO handle deleted files from VSS
    // TODO identify local files
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    int exitCode;
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("Executing: " + cl.getWorkingDirectory().getAbsolutePath() + ">>" + cl.toString());
    }
    exitCode = VssCommandLineUtils.executeCommandline(cl, consumer, stderr, getLogger());
    if (exitCode != 0) {
        String error = stderr.getOutput();
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("VSS returns error: [" + error + "] return code: [" + exitCode + "]");
        }
        if (error.indexOf("A writable copy of") < 0) {
            return new UpdateScmResult(cl.toString(), "The vss command failed.", error, false);
        }
        // print out the writable copy for manual handling
        if (getLogger().isWarnEnabled()) {
            getLogger().warn(error);
        }
    }
    return new UpdateScmResult(cl.toString(), consumer.getUpdatedFiles());
}
Also used : Commandline(org.codehaus.plexus.util.cli.Commandline) VssScmProviderRepository(org.apache.maven.scm.provider.vss.repository.VssScmProviderRepository) VssCommandLineUtils(org.apache.maven.scm.provider.vss.commands.VssCommandLineUtils) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) UpdateScmResult(org.apache.maven.scm.command.update.UpdateScmResult)

Example 9 with VssScmProviderRepository

use of org.apache.maven.scm.provider.vss.repository.VssScmProviderRepository in project maven-scm by apache.

the class VssScmProviderTest method testUrl.

private void testUrl(String scmUrl, String expectedVssDir, String expectedProjectPath, String expectedUser, String expectedPassword) throws Exception {
    ScmRepository repository = scmManager.makeScmRepository(scmUrl);
    assertNotNull("ScmManager.makeScmRepository() returned null", repository);
    assertNotNull("The provider repository was null.", repository.getProviderRepository());
    assertTrue("The SCM Repository isn't a " + VssScmProviderRepository.class.getName() + ".", repository.getProviderRepository() instanceof VssScmProviderRepository);
    VssScmProviderRepository providerRepository = (VssScmProviderRepository) repository.getProviderRepository();
    assertEquals("vssdir is incorrect", expectedVssDir, providerRepository.getVssdir());
    assertEquals("projectPath is incorrect", expectedProjectPath, providerRepository.getProject());
    assertEquals("User is incorrect", expectedUser, providerRepository.getUser());
    assertEquals("Password is incorrect", expectedPassword, providerRepository.getPassword());
}
Also used : ScmRepository(org.apache.maven.scm.repository.ScmRepository) VssScmProviderRepository(org.apache.maven.scm.provider.vss.repository.VssScmProviderRepository)

Aggregations

VssScmProviderRepository (org.apache.maven.scm.provider.vss.repository.VssScmProviderRepository)9 VssCommandLineUtils (org.apache.maven.scm.provider.vss.commands.VssCommandLineUtils)8 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)8 Commandline (org.codehaus.plexus.util.cli.Commandline)8 ScmFile (org.apache.maven.scm.ScmFile)2 ChangeLogScmResult (org.apache.maven.scm.command.changelog.ChangeLogScmResult)2 ArrayList (java.util.ArrayList)1 ScmException (org.apache.maven.scm.ScmException)1 AddScmResult (org.apache.maven.scm.command.add.AddScmResult)1 ChangeLogSet (org.apache.maven.scm.command.changelog.ChangeLogSet)1 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)1 CheckOutScmResult (org.apache.maven.scm.command.checkout.CheckOutScmResult)1 EditScmResult (org.apache.maven.scm.command.edit.EditScmResult)1 StatusScmResult (org.apache.maven.scm.command.status.StatusScmResult)1 TagScmResult (org.apache.maven.scm.command.tag.TagScmResult)1 UpdateScmResult (org.apache.maven.scm.command.update.UpdateScmResult)1 ScmRepository (org.apache.maven.scm.repository.ScmRepository)1