Search in sources :

Example 16 with PerforceScmProviderRepository

use of org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository in project maven-scm by apache.

the class PerforceTagCommandTest method testCommandLine.

// ----------------------------------------------------------------------
// 
// ----------------------------------------------------------------------
private void testCommandLine(String tag, String create, String sync) throws Exception {
    ScmRepository repository = getScmManager().makeScmRepository("scm:perforce://depot/projects/pathname");
    PerforceScmProviderRepository svnRepository = (PerforceScmProviderRepository) repository.getProviderRepository();
    ScmFileSet files = new ScmFileSet(new File("."), Arrays.asList(new File[] { new File("foo.xml"), new File("bar.xml") }));
    Commandline cl1 = PerforceTagCommand.createLabelCommandLine(svnRepository, workingDirectory);
    assertCommandLine(create, null, cl1);
    Commandline cl2 = PerforceTagCommand.createLabelsyncCommandLine(svnRepository, workingDirectory, files, tag);
    assertCommandLine(sync, null, cl2);
}
Also used : ScmRepository(org.apache.maven.scm.repository.ScmRepository) ScmFileSet(org.apache.maven.scm.ScmFileSet) Commandline(org.codehaus.plexus.util.cli.Commandline) PerforceScmProviderRepository(org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository) File(java.io.File)

Example 17 with PerforceScmProviderRepository

use of org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository in project maven-scm by apache.

the class PerforceCheckInCommand method executeCheckInCommand.

/**
 * {@inheritDoc}
 */
@Override
protected CheckInScmResult executeCheckInCommand(ScmProviderRepository repo, ScmFileSet files, String message, ScmVersion version) throws ScmException {
    Commandline cl = createCommandLine((PerforceScmProviderRepository) repo, files.getBasedir());
    PerforceCheckInConsumer consumer = new PerforceCheckInConsumer();
    try {
        String jobs = System.getProperty("maven.scm.jobs");
        if (getLogger().isDebugEnabled()) {
            getLogger().debug(PerforceScmProvider.clean("Executing " + cl.toString()));
        }
        PerforceScmProviderRepository prepo = (PerforceScmProviderRepository) repo;
        String changes = createChangeListSpecification(prepo, files, message, PerforceScmProvider.getRepoPath(getLogger(), prepo, files.getBasedir()), jobs);
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Sending changelist:\n" + changes);
        }
        CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
        int exitCode = CommandLineUtils.executeCommandLine(cl, new ByteArrayInputStream(changes.getBytes()), consumer, err);
        if (exitCode != 0) {
            String cmdLine = CommandLineUtils.toString(cl.getCommandline());
            StringBuilder msg = new StringBuilder("Exit code: " + exitCode + " - " + err.getOutput());
            msg.append('\n');
            msg.append("Command line was:" + cmdLine);
            throw new CommandLineException(msg.toString());
        }
    } catch (CommandLineException e) {
        if (getLogger().isErrorEnabled()) {
            getLogger().error("CommandLineException " + e.getMessage(), e);
        }
    }
    return new CheckInScmResult(cl.toString(), consumer.isSuccess() ? "Checkin successful" : "Unable to submit", consumer.getOutput(), consumer.isSuccess());
}
Also used : Commandline(org.codehaus.plexus.util.cli.Commandline) ByteArrayInputStream(java.io.ByteArrayInputStream) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) PerforceScmProviderRepository(org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository) CheckInScmResult(org.apache.maven.scm.command.checkin.CheckInScmResult) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException)

Example 18 with PerforceScmProviderRepository

use of org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository in project maven-scm by apache.

the class PerforceStatusCommand method executeStatusCommand.

/**
 * {@inheritDoc}
 */
protected StatusScmResult executeStatusCommand(ScmProviderRepository repo, ScmFileSet files) throws ScmException {
    PerforceScmProviderRepository prepo = (PerforceScmProviderRepository) repo;
    actualLocation = PerforceScmProvider.getRepoPath(getLogger(), prepo, files.getBasedir());
    PerforceStatusConsumer consumer = new PerforceStatusConsumer();
    Commandline command = readOpened(prepo, files, consumer);
    if (consumer.isSuccess()) {
        List<ScmFile> scmfiles = createResults(actualLocation, consumer);
        return new StatusScmResult(command.toString(), scmfiles);
    }
    return new StatusScmResult(command.toString(), "Unable to get status", consumer.getOutput(), consumer.isSuccess());
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) Commandline(org.codehaus.plexus.util.cli.Commandline) PerforceScmProviderRepository(org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository) ScmFile(org.apache.maven.scm.ScmFile)

Example 19 with PerforceScmProviderRepository

use of org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository in project maven-scm by apache.

the class PerforceTagCommand method executeTagCommand.

/**
 * {@inheritDoc}
 */
protected ScmResult executeTagCommand(ScmProviderRepository repo, ScmFileSet files, String tag, ScmTagParameters scmTagParameters) throws ScmException {
    PerforceScmProviderRepository prepo = (PerforceScmProviderRepository) repo;
    actualRepoLocation = PerforceScmProvider.getRepoPath(getLogger(), prepo, files.getBasedir());
    PerforceTagConsumer consumer = new PerforceTagConsumer();
    createLabel(repo, files, tag, consumer, false);
    if (consumer.isSuccess()) {
        syncLabel(repo, files, tag, consumer);
    }
    if (consumer.isSuccess()) {
        // Now update the label if we need to lock it
        if (shouldLock()) {
            consumer = new PerforceTagConsumer();
            createLabel(repo, files, tag, consumer, true);
        }
    }
    if (consumer.isSuccess()) {
        // Unclear what to pass as the first arg
        return new TagScmResult("p4 label -i", consumer.getTagged());
    }
    // Unclear what to pass as the first arg
    return new TagScmResult("p4 label -i", "Tag failed", consumer.getOutput(), false);
}
Also used : TagScmResult(org.apache.maven.scm.command.tag.TagScmResult) PerforceScmProviderRepository(org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository)

Example 20 with PerforceScmProviderRepository

use of org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository in project maven-scm by apache.

the class PerforceChangeLogCommandTest method testCommandLineDates.

private void testCommandLineDates(String commandLine, Date date1, Date date2) throws Exception {
    ScmRepository repository = getScmManager().makeScmRepository("scm:perforce://depot/projects/pathname");
    PerforceScmProviderRepository repo = (PerforceScmProviderRepository) repository.getProviderRepository();
    Commandline cl = PerforceChangeLogCommand.createCommandLine(repo, workingDirectory, System.getProperty(PerforceScmProvider.DEFAULT_CLIENTSPEC_PROPERTY), null, date1, date2, null, null);
    assertCommandLine(commandLine, null, cl);
}
Also used : ScmRepository(org.apache.maven.scm.repository.ScmRepository) Commandline(org.codehaus.plexus.util.cli.Commandline) PerforceScmProviderRepository(org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository)

Aggregations

PerforceScmProviderRepository (org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository)31 ScmRepository (org.apache.maven.scm.repository.ScmRepository)23 Commandline (org.codehaus.plexus.util.cli.Commandline)19 File (java.io.File)6 ScmFileSet (org.apache.maven.scm.ScmFileSet)5 CommandLineException (org.codehaus.plexus.util.cli.CommandLineException)5 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)5 ByteArrayInputStream (java.io.ByteArrayInputStream)2 CheckOutScmResult (org.apache.maven.scm.command.checkout.CheckOutScmResult)2 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 HashSet (java.util.HashSet)1 CommandParameters (org.apache.maven.scm.CommandParameters)1 ScmException (org.apache.maven.scm.ScmException)1 ScmFile (org.apache.maven.scm.ScmFile)1 ScmRevision (org.apache.maven.scm.ScmRevision)1 BlameLine (org.apache.maven.scm.command.blame.BlameLine)1 BlameScmResult (org.apache.maven.scm.command.blame.BlameScmResult)1 ChangeLogScmResult (org.apache.maven.scm.command.changelog.ChangeLogScmResult)1