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);
}
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());
}
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());
}
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);
}
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);
}
Aggregations