Search in sources :

Example 21 with ScmTag

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

the class AccuRevTagCommandTckTest method testReleasePluginStyleTagThenCheckout.

@SuppressWarnings("deprecation")
@Test
public void testReleasePluginStyleTagThenCheckout() throws Exception {
    String tag = "test-tag";
    makeFile(getWorkingCopy(), ".acignore", "target/*\ntarget\n");
    ScmRepository scmRepository = getScmRepository();
    addToWorkingTree(getWorkingCopy(), new File(".acignore"), scmRepository);
    CheckInScmResult checkinResult = getScmManager().checkIn(scmRepository, new ScmFileSet(getWorkingCopy()), "add acignore");
    assertResultIsSuccess(checkinResult);
    TagScmResult tagResult = getScmManager().getProviderByUrl(getScmUrl()).tag(scmRepository, new ScmFileSet(getWorkingCopy()), tag);
    assertResultIsSuccess(tagResult);
    scmRepository.getProviderRepository().setPersistCheckout(false);
    CheckOutScmResult checkoutResult = getScmManager().checkOut(scmRepository, new ScmFileSet(new File(getWorkingCopy(), "target/checkout")), new ScmTag(tag));
    assertResultIsSuccess(checkoutResult);
}
Also used : ScmRepository(org.apache.maven.scm.repository.ScmRepository) ScmFileSet(org.apache.maven.scm.ScmFileSet) ScmTag(org.apache.maven.scm.ScmTag) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult) TagScmResult(org.apache.maven.scm.command.tag.TagScmResult) File(java.io.File) CheckInScmResult(org.apache.maven.scm.command.checkin.CheckInScmResult) Test(org.junit.Test) TagCommandTckTest(org.apache.maven.scm.tck.command.tag.TagCommandTckTest)

Example 22 with ScmTag

use of org.apache.maven.scm.ScmTag 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 23 with ScmTag

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

the class SvnChangeLogCommand method createCommandLine.

public static Commandline createCommandLine(SvnScmProviderRepository repository, File workingDirectory, ScmBranch branch, Date startDate, Date endDate, ScmVersion startVersion, ScmVersion endVersion, Integer limit) {
    SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
    dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
    Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(workingDirectory, repository);
    cl.createArg().setValue("log");
    cl.createArg().setValue("-v");
    if (limit != null && limit > 0) {
        cl.createArg().setValue("--limit");
        cl.createArg().setValue(Integer.toString(limit));
    }
    if (startDate != null) {
        cl.createArg().setValue("-r");
        if (endDate != null) {
            cl.createArg().setValue("{" + dateFormat.format(startDate) + "}" + ":" + "{" + dateFormat.format(endDate) + "}");
        } else {
            cl.createArg().setValue("{" + dateFormat.format(startDate) + "}:HEAD");
        }
    }
    if (startVersion != null) {
        cl.createArg().setValue("-r");
        if (endVersion != null) {
            if (startVersion.getName().equals(endVersion.getName())) {
                cl.createArg().setValue(startVersion.getName());
            } else {
                cl.createArg().setValue(startVersion.getName() + ":" + endVersion.getName());
            }
        } else {
            cl.createArg().setValue(startVersion.getName() + ":HEAD");
        }
    }
    if (branch != null && StringUtils.isNotEmpty(branch.getName())) {
        // the changelog of that branch, but limit it to paths that also occur in this repository.
        if (branch instanceof ScmTag) {
            cl.createArg().setValue(SvnTagBranchUtils.resolveTagUrl(repository, (ScmTag) branch));
        } else {
            cl.createArg().setValue(SvnTagBranchUtils.resolveBranchUrl(repository, branch));
        }
    }
    if (endVersion == null || !StringUtils.equals("BASE", endVersion.getName())) {
        cl.createArg().setValue(repository.getUrl());
    }
    return cl;
}
Also used : Commandline(org.codehaus.plexus.util.cli.Commandline) ScmTag(org.apache.maven.scm.ScmTag) SimpleDateFormat(java.text.SimpleDateFormat)

Example 24 with ScmTag

use of org.apache.maven.scm.ScmTag 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 25 with ScmTag

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

the class SvnTagCommand method createCommandLine.

// ----------------------------------------------------------------------
// 
// ----------------------------------------------------------------------
/**
 * @deprecated
 * @param repository
 * @param workingDirectory
 * @param tag
 * @param messageFile
 * @return
 */
public static Commandline createCommandLine(SvnScmProviderRepository repository, File workingDirectory, String tag, File messageFile) {
    Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(workingDirectory, repository);
    cl.createArg().setValue("copy");
    cl.createArg().setValue("--parents");
    cl.createArg().setValue("--file");
    cl.createArg().setValue(messageFile.getAbsolutePath());
    cl.createArg().setValue(".");
    // Note: this currently assumes you have the tag base checked out too
    String tagUrl = SvnTagBranchUtils.resolveTagUrl(repository, new ScmTag(tag));
    cl.createArg().setValue(SvnCommandUtils.fixUrl(tagUrl, repository.getUser()));
    return cl;
}
Also used : Commandline(org.codehaus.plexus.util.cli.Commandline) ScmTag(org.apache.maven.scm.ScmTag)

Aggregations

ScmTag (org.apache.maven.scm.ScmTag)32 File (java.io.File)17 ScmFileSet (org.apache.maven.scm.ScmFileSet)17 CheckOutScmResult (org.apache.maven.scm.command.checkout.CheckOutScmResult)9 Commandline (org.codehaus.plexus.util.cli.Commandline)9 Test (org.junit.Test)9 AbstractAccuRevCommandTest (org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)8 CommandParameters (org.apache.maven.scm.CommandParameters)7 ScmFileMatcher.assertHasScmFile (org.apache.maven.scm.ScmFileMatcher.assertHasScmFile)7 ExportScmResult (org.apache.maven.scm.command.export.ExportScmResult)6 ScmBranch (org.apache.maven.scm.ScmBranch)5 ScmRepository (org.apache.maven.scm.repository.ScmRepository)5 ScmException (org.apache.maven.scm.ScmException)4 SvnScmProviderRepository (org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository)4 ScmFile (org.apache.maven.scm.ScmFile)3 ScmManager (org.apache.maven.scm.manager.ScmManager)3 SimpleDateFormat (java.text.SimpleDateFormat)2 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)2 TagScmResult (org.apache.maven.scm.command.tag.TagScmResult)2 SvnCommandLineUtils (org.apache.maven.scm.provider.svn.svnexe.command.SvnCommandLineUtils)2