Search in sources :

Example 16 with ScmBranch

use of org.apache.maven.scm.ScmBranch in project maven-scm by apache.

the class ClearCaseChangeLogCommandTest method testGetCommandLineWithTag.

public void testGetCommandLineWithTag() throws Exception {
    Date startDate = null;
    Date endDate = null;
    testCommandLine(new ScmBranch("myBranch"), startDate, endDate, "cleartool lshistory -fmt \"NAME:%En\\nDATE:%Nd\\nCOMM:%-12.12o - %o - %c - Activity: %[activity]p\\nUSER:%u\\nREVI:%Ln\\n\" -recurse -nco -branch myBranch");
}
Also used : ScmBranch(org.apache.maven.scm.ScmBranch) Date(java.util.Date)

Example 17 with ScmBranch

use of org.apache.maven.scm.ScmBranch in project maven-scm by apache.

the class JazzCheckOutCommand method createJazzLoadCommand.

public JazzScmCommand createJazzLoadCommand(JazzScmProviderRepository repo, ScmFileSet fileSet, ScmVersion scmVersion) {
    JazzScmCommand command = new JazzScmCommand(JazzConstants.CMD_LOAD, JazzConstants.ARG_FORCE, repo, fileSet, getLogger());
    if (fileSet != null) {
        command.addArgument(JazzConstants.ARG_LOCAL_WORKSPACE_PATH);
        command.addArgument(fileSet.getBasedir().getAbsolutePath());
    }
    // This works in tandem with the Tag Command.
    // Currently, RTC can not check out directly from a snapshot.
    // So, as a work around, the Tag Command creates a workspace name of the same name as the snapshot.
    // The functionality here (in using the ScmTag or ScmBranch) assumes that the workspace has been
    // created as a part of the Tag Command.
    String workspace = repo.getRepositoryWorkspace();
    if (scmVersion != null && StringUtils.isNotEmpty(scmVersion.getName())) {
        // Just in case we ever do something different for Tags (snapshots) and Branches (streams)
        if (scmVersion instanceof ScmTag) {
            workspace = scmVersion.getName();
        } else if (scmVersion instanceof ScmBranch) {
            workspace = scmVersion.getName();
        }
    }
    command.addArgument(workspace);
    return command;
}
Also used : ScmBranch(org.apache.maven.scm.ScmBranch) ScmTag(org.apache.maven.scm.ScmTag) JazzScmCommand(org.apache.maven.scm.provider.jazz.command.JazzScmCommand)

Example 18 with ScmBranch

use of org.apache.maven.scm.ScmBranch in project maven-scm by apache.

the class SvnBranchCommand method createCommandLine.

public static Commandline createCommandLine(SvnScmProviderRepository repository, File workingDirectory, String branch, File messageFile, ScmBranchParameters scmBranchParameters) {
    Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(workingDirectory, repository);
    cl.createArg().setValue("copy");
    cl.createArg().setValue("--parents");
    cl.createArg().setValue("--file");
    cl.createArg().setValue(messageFile.getAbsolutePath());
    if (scmBranchParameters != null && scmBranchParameters.isRemoteBranching()) {
        if (StringUtils.isNotBlank(scmBranchParameters.getScmRevision())) {
            cl.createArg().setValue("--revision");
            cl.createArg().setValue(scmBranchParameters.getScmRevision());
        }
        cl.createArg().setValue(SvnCommandUtils.fixUrl(repository.getUrl(), repository.getUser()));
    } else {
        cl.createArg().setValue(".");
    }
    // Note: this currently assumes you have the branch base checked out too
    String branchUrl = SvnTagBranchUtils.resolveBranchUrl(repository, new ScmBranch(branch));
    cl.createArg().setValue(SvnCommandUtils.fixUrl(branchUrl, repository.getUser()));
    return cl;
}
Also used : ScmBranch(org.apache.maven.scm.ScmBranch) Commandline(org.codehaus.plexus.util.cli.Commandline)

Example 19 with ScmBranch

use of org.apache.maven.scm.ScmBranch in project maven-scm by apache.

the class SvnCheckOutCommand method executeCheckOutCommand.

/**
 * {@inheritDoc}
 */
protected CheckOutScmResult executeCheckOutCommand(ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion version, boolean recursive, boolean shallow) throws ScmException {
    SvnScmProviderRepository repository = (SvnScmProviderRepository) repo;
    String url = repository.getUrl();
    if (version != null && StringUtils.isNotEmpty(version.getName())) {
        if (version instanceof ScmTag) {
            url = SvnTagBranchUtils.resolveTagUrl(repository, (ScmTag) version);
        } else if (version instanceof ScmBranch) {
            url = SvnTagBranchUtils.resolveBranchUrl(repository, (ScmBranch) version);
        }
    }
    url = SvnCommandUtils.fixUrl(url, repository.getUser());
    Commandline cl = createCommandLine(repository, fileSet.getBasedir(), version, url, recursive);
    SvnCheckOutConsumer consumer = new SvnCheckOutConsumer(getLogger(), fileSet.getBasedir());
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    int exitCode;
    if (getLogger().isInfoEnabled()) {
        getLogger().info("Executing: " + SvnCommandLineUtils.cryptPassword(cl));
        if (Os.isFamily(Os.FAMILY_WINDOWS)) {
            getLogger().info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath());
        }
    }
    try {
        exitCode = SvnCommandLineUtils.execute(cl, consumer, stderr, getLogger());
    } catch (CommandLineException ex) {
        throw new ScmException("Error while executing command.", ex);
    }
    if (exitCode != 0) {
        return new CheckOutScmResult(cl.toString(), "The svn command failed.", stderr.getOutput(), false);
    }
    return new CheckOutScmResult(cl.toString(), Integer.toString(consumer.getRevision()), consumer.getCheckedOutFiles());
}
Also used : ScmBranch(org.apache.maven.scm.ScmBranch) ScmException(org.apache.maven.scm.ScmException) Commandline(org.codehaus.plexus.util.cli.Commandline) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException) ScmTag(org.apache.maven.scm.ScmTag) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) SvnCommandLineUtils(org.apache.maven.scm.provider.svn.svnexe.command.SvnCommandLineUtils) SvnScmProviderRepository(org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult)

Example 20 with ScmBranch

use of org.apache.maven.scm.ScmBranch in project maven-scm by apache.

the class SvnUpdateCommand method createCommandLine.

// ----------------------------------------------------------------------
// 
// ----------------------------------------------------------------------
public static Commandline createCommandLine(SvnScmProviderRepository repository, File workingDirectory, ScmVersion version) {
    Settings settings = SvnUtil.getSettings();
    String workingDir = workingDirectory.getAbsolutePath();
    if (settings.isUseCygwinPath()) {
        workingDir = settings.getCygwinMountPath() + "/" + workingDir;
        workingDir = StringUtils.replace(workingDir, ":", "");
        workingDir = StringUtils.replace(workingDir, "\\", "/");
    }
    if (version != null && StringUtils.isEmpty(version.getName())) {
        version = null;
    }
    Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(workingDirectory, repository);
    if (version == null || SvnTagBranchUtils.isRevisionSpecifier(version)) {
        cl.createArg().setValue("update");
        if (version != null && StringUtils.isNotEmpty(version.getName())) {
            cl.createArg().setValue("-r");
            cl.createArg().setValue(version.getName());
        }
        cl.createArg().setValue(workingDir);
    } else {
        if (version instanceof ScmBranch) {
            // The tag specified does not appear to be numeric, so assume it refers
            // to a branch/tag url and perform a switch operation rather than update
            cl.createArg().setValue("switch");
            if (version instanceof ScmTag) {
                cl.createArg().setValue(SvnTagBranchUtils.resolveTagUrl(repository, (ScmTag) version));
            } else {
                cl.createArg().setValue(SvnTagBranchUtils.resolveBranchUrl(repository, (ScmBranch) version));
            }
            cl.createArg().setValue(workingDir);
        }
    }
    return cl;
}
Also used : ScmBranch(org.apache.maven.scm.ScmBranch) Commandline(org.codehaus.plexus.util.cli.Commandline) ScmTag(org.apache.maven.scm.ScmTag) Settings(org.apache.maven.scm.providers.svn.settings.Settings)

Aggregations

ScmBranch (org.apache.maven.scm.ScmBranch)25 Date (java.util.Date)9 ScmException (org.apache.maven.scm.ScmException)9 ScmFileSet (org.apache.maven.scm.ScmFileSet)7 Commandline (org.codehaus.plexus.util.cli.Commandline)7 ScmTag (org.apache.maven.scm.ScmTag)5 ChangeLogScmResult (org.apache.maven.scm.command.changelog.ChangeLogScmResult)5 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)5 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)4 ScmVersion (org.apache.maven.scm.ScmVersion)4 ScmProvider (org.apache.maven.scm.provider.ScmProvider)4 File (java.io.File)3 ChangeSet (org.apache.maven.scm.ChangeSet)3 ScmRevision (org.apache.maven.scm.ScmRevision)3 ChangeLogSet (org.apache.maven.scm.command.changelog.ChangeLogSet)3 SvnScmProviderRepository (org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository)3 ScmRepository (org.apache.maven.scm.repository.ScmRepository)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 CheckOutScmResult (org.apache.maven.scm.command.checkout.CheckOutScmResult)2