Search in sources :

Example 1 with JazzStatusCommand

use of org.apache.maven.scm.provider.jazz.command.status.JazzStatusCommand in project maven-scm by apache.

the class JazzScmProvider method tag.

/**
 * {@inheritDoc}
 */
protected TagScmResult tag(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
    getLogger().debug("JazzScmProvider:tag()");
    // We need to call the status command first, so that we can get the details of the stream etc.
    // This is needed for workspace deliveries and snapshot promotions.
    JazzStatusCommand statusCommand = new JazzStatusCommand();
    statusCommand.setLogger(getLogger());
    statusCommand.execute(repository, fileSet, parameters);
    JazzTagCommand command = new JazzTagCommand();
    command.setLogger(getLogger());
    return (TagScmResult) command.execute(repository, fileSet, parameters);
}
Also used : JazzStatusCommand(org.apache.maven.scm.provider.jazz.command.status.JazzStatusCommand) TagScmResult(org.apache.maven.scm.command.tag.TagScmResult) JazzTagCommand(org.apache.maven.scm.provider.jazz.command.tag.JazzTagCommand)

Example 2 with JazzStatusCommand

use of org.apache.maven.scm.provider.jazz.command.status.JazzStatusCommand in project maven-scm by apache.

the class JazzAddCommand method executeAddCommand.

public AddScmResult executeAddCommand(ScmProviderRepository repo, ScmFileSet fileSet) throws ScmException {
    // NOTE: THIS IS ALSO CALLED DIRECTLY FROM THE CHECKIN COMMAND.
    // 
    // The "checkin" command does not produce consumable output as to which individual files were checked in. (in
    // 2.0.0.2 at least). Since only "locally modified" changes get checked in, we call a "status" command to
    // generate a list of these files.
    File baseDir = fileSet.getBasedir();
    File parentFolder = (baseDir.getParentFile() != null) ? baseDir.getParentFile() : baseDir;
    List<ScmFile> changedScmFiles = new ArrayList<ScmFile>();
    List<File> changedFiles = new ArrayList<File>();
    List<ScmFile> commitedFiles = new ArrayList<ScmFile>();
    JazzStatusCommand statusCmd = new JazzStatusCommand();
    statusCmd.setLogger(getLogger());
    StatusScmResult statusCmdResult = statusCmd.executeStatusCommand(repo, fileSet);
    List<ScmFile> statusScmFiles = statusCmdResult.getChangedFiles();
    for (ScmFile file : statusScmFiles) {
        getLogger().debug("Iterating over statusScmFiles: " + file);
        if (file.getStatus() == ScmFileStatus.ADDED || file.getStatus() == ScmFileStatus.DELETED || file.getStatus() == ScmFileStatus.MODIFIED) {
            changedScmFiles.add(new ScmFile(file.getPath(), ScmFileStatus.CHECKED_IN));
            changedFiles.add(new File(parentFolder, file.getPath()));
        }
    }
    List<File> files = fileSet.getFileList();
    if (files.size() == 0) {
        // Either commit all local changes
        commitedFiles = changedScmFiles;
    } else {
        // Or commit specific files
        for (File file : files) {
            if (fileExistsInFileList(file, changedFiles)) {
                commitedFiles.add(new ScmFile(file.getPath(), ScmFileStatus.CHECKED_IN));
            }
        }
    }
    // Now that we have a list of files to process, we can "add" (scm checkin) them.
    JazzAddConsumer addConsumer = new JazzAddConsumer(repo, getLogger());
    ErrorConsumer errConsumer = new ErrorConsumer(getLogger());
    JazzScmCommand command = createAddCommand(repo, fileSet);
    int status = command.execute(addConsumer, errConsumer);
    if (status != 0) {
        return new AddScmResult(command.getCommandString(), "Error code for Jazz SCM add (checkin) command - " + status, errConsumer.getOutput(), false);
    }
    return new AddScmResult(command.getCommandString(), addConsumer.getFiles());
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) JazzStatusCommand(org.apache.maven.scm.provider.jazz.command.status.JazzStatusCommand) ErrorConsumer(org.apache.maven.scm.provider.jazz.command.consumer.ErrorConsumer) AddScmResult(org.apache.maven.scm.command.add.AddScmResult) ArrayList(java.util.ArrayList) JazzScmCommand(org.apache.maven.scm.provider.jazz.command.JazzScmCommand) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) ScmFile(org.apache.maven.scm.ScmFile)

Example 3 with JazzStatusCommand

use of org.apache.maven.scm.provider.jazz.command.status.JazzStatusCommand in project maven-scm by apache.

the class JazzDiffCommand method executeDiffCommand.

/**
 * {@inheritDoc}
 */
protected DiffScmResult executeDiffCommand(ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion startRevision, ScmVersion endRevision) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("Executing diff command...");
    }
    File baseDir = fileSet.getBasedir();
    File parentFolder = (baseDir.getParentFile() != null) ? baseDir.getParentFile() : baseDir;
    // First execute the status command to get the list of changed files.
    JazzStatusCommand statusCmd = new JazzStatusCommand();
    statusCmd.setLogger(getLogger());
    StatusScmResult statusCmdResult = statusCmd.executeStatusCommand(repo, fileSet);
    List<ScmFile> statusScmFiles = statusCmdResult.getChangedFiles();
    // In this case, we also use it across multiple calls to "scm diff" so that we
    // sum all output into on.
    JazzScmCommand diffCmd = null;
    StringBuilder patch = new StringBuilder();
    Map<String, CharSequence> differences = new HashMap<String, CharSequence>();
    // Now lets iterate through them
    for (ScmFile file : statusScmFiles) {
        if (file.getStatus() == ScmFileStatus.MODIFIED) {
            // The "scm status" command returns files relative to the sandbox root.
            // Whereas the "scm diff" command needs them relative to the working directory.
            File fullPath = new File(parentFolder, file.getPath());
            String relativePath = fullPath.toString().substring(baseDir.toString().length());
            getLogger().debug("Full Path     : '" + fullPath + "'");
            getLogger().debug("Relative Path : '" + relativePath + "'");
            // Now call "scm diff on it"
            // In this case, we use the DebugLoggerConsumer's ability to store captured output
            DebugLoggerConsumer diffConsumer = new DebugLoggerConsumer(getLogger());
            ErrorConsumer errConsumer = new ErrorConsumer(getLogger());
            diffCmd = createDiffCommand(repo, fileSet, relativePath);
            int status = diffCmd.execute(diffConsumer, errConsumer);
            if (status != 0) {
                // Return a false result (not the usual SCMResult)
                return new DiffScmResult(diffCmd.toString(), "The scm diff command failed.", errConsumer.getOutput(), false);
            }
            // Append to patch (all combined)
            patch.append(diffConsumer.getOutput());
            // Set the differences map <File, <CharSequence>
            differences.put(relativePath, diffConsumer.getOutput());
        }
    }
    return new DiffScmResult(diffCmd.toString(), statusCmdResult.getChangedFiles(), differences, patch.toString());
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) HashMap(java.util.HashMap) ErrorConsumer(org.apache.maven.scm.provider.jazz.command.consumer.ErrorConsumer) JazzScmCommand(org.apache.maven.scm.provider.jazz.command.JazzScmCommand) ScmFile(org.apache.maven.scm.ScmFile) JazzStatusCommand(org.apache.maven.scm.provider.jazz.command.status.JazzStatusCommand) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) DebugLoggerConsumer(org.apache.maven.scm.provider.jazz.command.consumer.DebugLoggerConsumer) DiffScmResult(org.apache.maven.scm.command.diff.DiffScmResult)

Example 4 with JazzStatusCommand

use of org.apache.maven.scm.provider.jazz.command.status.JazzStatusCommand in project maven-scm by apache.

the class JazzScmProvider method changelog.

/**
 * {@inheritDoc}
 */
protected ChangeLogScmResult changelog(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
    getLogger().debug("JazzScmProvider:changelog()");
    // We need to call the status command first, so that we can get the details of the workspace.
    // This is needed for the list changesets command.
    // We could also 'trust' the value in the pom.
    JazzStatusCommand statusCommand = new JazzStatusCommand();
    statusCommand.setLogger(getLogger());
    statusCommand.execute(repository, fileSet, parameters);
    JazzChangeLogCommand command = new JazzChangeLogCommand();
    command.setLogger(getLogger());
    return (ChangeLogScmResult) command.execute(repository, fileSet, parameters);
}
Also used : JazzChangeLogCommand(org.apache.maven.scm.provider.jazz.command.changelog.JazzChangeLogCommand) JazzStatusCommand(org.apache.maven.scm.provider.jazz.command.status.JazzStatusCommand) ChangeLogScmResult(org.apache.maven.scm.command.changelog.ChangeLogScmResult)

Example 5 with JazzStatusCommand

use of org.apache.maven.scm.provider.jazz.command.status.JazzStatusCommand in project maven-scm by apache.

the class JazzScmProvider method status.

/**
 * {@inheritDoc}
 */
protected StatusScmResult status(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
    getLogger().debug("JazzScmProvider:status()");
    JazzStatusCommand command = new JazzStatusCommand();
    command.setLogger(getLogger());
    return (StatusScmResult) command.execute(repository, fileSet, parameters);
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) JazzStatusCommand(org.apache.maven.scm.provider.jazz.command.status.JazzStatusCommand)

Aggregations

JazzStatusCommand (org.apache.maven.scm.provider.jazz.command.status.JazzStatusCommand)7 StatusScmResult (org.apache.maven.scm.command.status.StatusScmResult)3 JazzScmCommand (org.apache.maven.scm.provider.jazz.command.JazzScmCommand)3 ErrorConsumer (org.apache.maven.scm.provider.jazz.command.consumer.ErrorConsumer)3 File (java.io.File)2 ScmFile (org.apache.maven.scm.ScmFile)2 DebugLoggerConsumer (org.apache.maven.scm.provider.jazz.command.consumer.DebugLoggerConsumer)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ScmException (org.apache.maven.scm.ScmException)1 AddScmResult (org.apache.maven.scm.command.add.AddScmResult)1 ChangeLogScmResult (org.apache.maven.scm.command.changelog.ChangeLogScmResult)1 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)1 DiffScmResult (org.apache.maven.scm.command.diff.DiffScmResult)1 ListScmResult (org.apache.maven.scm.command.list.ListScmResult)1 TagScmResult (org.apache.maven.scm.command.tag.TagScmResult)1 JazzChangeLogCommand (org.apache.maven.scm.provider.jazz.command.changelog.JazzChangeLogCommand)1 JazzListCommand (org.apache.maven.scm.provider.jazz.command.list.JazzListCommand)1 JazzTagCommand (org.apache.maven.scm.provider.jazz.command.tag.JazzTagCommand)1 JazzScmProviderRepository (org.apache.maven.scm.provider.jazz.repository.JazzScmProviderRepository)1