Search in sources :

Example 6 with ScmVersion

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

the class AbstractScmProvider method diff.

/**
 * {@inheritDoc}
 *
 * @deprecated
 */
public DiffScmResult diff(ScmRepository repository, ScmFileSet fileSet, String startRevision, String endRevision) throws ScmException {
    ScmVersion startVersion = null;
    ScmVersion endVersion = null;
    if (StringUtils.isNotEmpty(startRevision)) {
        startVersion = new ScmRevision(startRevision);
    }
    if (StringUtils.isNotEmpty(endRevision)) {
        endVersion = new ScmRevision(endRevision);
    }
    return diff(repository, fileSet, startVersion, endVersion);
}
Also used : ScmRevision(org.apache.maven.scm.ScmRevision) ScmVersion(org.apache.maven.scm.ScmVersion)

Example 7 with ScmVersion

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

the class AbstractChangeLogCommand method executeCommand.

/**
 * {@inheritDoc}
 */
public ScmResult executeCommand(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
    Date startDate = parameters.getDate(CommandParameter.START_DATE, null);
    Date endDate = parameters.getDate(CommandParameter.END_DATE, null);
    int numDays = parameters.getInt(CommandParameter.NUM_DAYS, 0);
    Integer limit = parameters.getInt(CommandParameter.LIMIT, -1);
    if (limit < 1) {
        limit = null;
    }
    ScmBranch branch = (ScmBranch) parameters.getScmVersion(CommandParameter.BRANCH, null);
    ScmVersion startVersion = parameters.getScmVersion(CommandParameter.START_SCM_VERSION, null);
    ScmVersion endVersion = parameters.getScmVersion(CommandParameter.END_SCM_VERSION, null);
    String datePattern = parameters.getString(CommandParameter.CHANGELOG_DATE_PATTERN, null);
    if (startVersion != null || endVersion != null) {
        return executeChangeLogCommand(repository, fileSet, startVersion, endVersion, datePattern);
    } else {
        if (numDays != 0 && (startDate != null || endDate != null)) {
            throw new ScmException("Start or end date cannot be set if num days is set.");
        }
        if (endDate != null && startDate == null) {
            throw new ScmException("The end date is set but the start date isn't.");
        }
        if (numDays > 0) {
            @SuppressWarnings("checkstyle:magicnumber") int day = 24 * 60 * 60 * 1000;
            startDate = new Date(System.currentTimeMillis() - (long) numDays * day);
            endDate = new Date(System.currentTimeMillis() + (long) day);
        } else if (endDate == null) {
            endDate = new Date();
        }
        return executeChangeLogCommand(repository, fileSet, startDate, endDate, branch, datePattern);
    }
}
Also used : ScmBranch(org.apache.maven.scm.ScmBranch) ScmException(org.apache.maven.scm.ScmException) Date(java.util.Date) ScmVersion(org.apache.maven.scm.ScmVersion)

Example 8 with ScmVersion

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

the class MavenScmCli method main.

// ----------------------------------------------------------------------
// 
// ----------------------------------------------------------------------
public static void main(String[] args) {
    MavenScmCli cli;
    try {
        cli = new MavenScmCli();
    } catch (Exception ex) {
        System.err.println("Error while starting Maven Scm.");
        ex.printStackTrace(System.err);
        return;
    }
    String scmUrl;
    String command;
    if (args.length != 3) {
        System.err.println("Usage: maven-scm-client <command> <working directory> <scm url> [<scmVersion> [<scmVersionType>]]");
        System.err.println("scmVersion is a branch name/tag name/revision number.");
        System.err.println("scmVersionType can be 'branch', 'tag', 'revision'. " + "The default value is 'revision'.");
        return;
    }
    command = args[0];
    // SCM-641
    File workingDirectory = new File(args[1]).getAbsoluteFile();
    scmUrl = args[2];
    ScmVersion scmVersion = null;
    if (args.length > 3) {
        String version = args[3];
        if (args.length > 4) {
            String type = args[4];
            if ("tag".equals(type)) {
                scmVersion = new ScmTag(version);
            } else if ("branch".equals(type)) {
                scmVersion = new ScmBranch(version);
            } else if ("revision".equals(type)) {
                scmVersion = new ScmRevision(version);
            } else {
                throw new IllegalArgumentException("'" + type + "' version type isn't known.");
            }
        } else {
            scmVersion = new ScmRevision(args[3]);
        }
    }
    cli.execute(scmUrl, command, workingDirectory, scmVersion);
    cli.stop();
}
Also used : ScmBranch(org.apache.maven.scm.ScmBranch) ScmTag(org.apache.maven.scm.ScmTag) ScmRevision(org.apache.maven.scm.ScmRevision) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) ScmRepositoryException(org.apache.maven.scm.repository.ScmRepositoryException) ScmException(org.apache.maven.scm.ScmException) NoSuchScmProviderException(org.apache.maven.scm.manager.NoSuchScmProviderException) ScmVersion(org.apache.maven.scm.ScmVersion)

Example 9 with ScmVersion

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

the class AbstractCheckInCommand method executeCommand.

public ScmResult executeCommand(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
    String message = parameters.getString(CommandParameter.MESSAGE);
    ScmVersion scmVersion = parameters.getScmVersion(CommandParameter.SCM_VERSION, null);
    return executeCheckInCommand(repository, fileSet, message, scmVersion);
}
Also used : ScmVersion(org.apache.maven.scm.ScmVersion)

Example 10 with ScmVersion

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

the class AbstractDiffCommand method executeCommand.

/**
 * {@inheritDoc}
 */
public ScmResult executeCommand(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
    ScmVersion startRevision = parameters.getScmVersion(CommandParameter.START_SCM_VERSION, null);
    ScmVersion endRevision = parameters.getScmVersion(CommandParameter.END_SCM_VERSION, null);
    return executeDiffCommand(repository, fileSet, startRevision, endRevision);
}
Also used : ScmVersion(org.apache.maven.scm.ScmVersion)

Aggregations

ScmVersion (org.apache.maven.scm.ScmVersion)19 ScmException (org.apache.maven.scm.ScmException)6 ScmBranch (org.apache.maven.scm.ScmBranch)4 ScmFileSet (org.apache.maven.scm.ScmFileSet)4 ScmRevision (org.apache.maven.scm.ScmRevision)4 File (java.io.File)3 Date (java.util.Date)3 ScmFile (org.apache.maven.scm.ScmFile)3 ChangeLogScmResult (org.apache.maven.scm.command.changelog.ChangeLogScmResult)3 ChangeLogSet (org.apache.maven.scm.command.changelog.ChangeLogSet)3 AccuRevVersion (org.apache.maven.scm.provider.accurev.AccuRevVersion)3 IOException (java.io.IOException)2 ChangeSet (org.apache.maven.scm.ChangeSet)2 ScmProviderRepository (org.apache.maven.scm.provider.ScmProviderRepository)2 AccuRev (org.apache.maven.scm.provider.accurev.AccuRev)2 AccuRevException (org.apache.maven.scm.provider.accurev.AccuRevException)2 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 ScmTag (org.apache.maven.scm.ScmTag)1