use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.
the class StatusCommandTckTest method testStatusCommand.
public void testStatusCommand() throws Exception {
ScmRepository repository = makeScmRepository(getScmUrl());
checkOut(getUpdatingCopy(), repository);
// ----------------------------------------------------------------------
// Change the files
// ----------------------------------------------------------------------
/*
* readme.txt is changed (changed file in the root directory)
* project.xml is added (added file in the root directory)
*/
// /readme.txt
this.edit(getWorkingCopy(), "readme.txt", null, getScmRepository());
ScmTestCase.makeFile(getWorkingCopy(), "/readme.txt", "changed readme.txt");
// /project.xml
ScmTestCase.makeFile(getWorkingCopy(), "/project.xml", "changed project.xml");
addToWorkingTree(getWorkingCopy(), new File("project.xml"), getScmRepository());
commit(getWorkingCopy(), getScmRepository());
// /pom.xml
this.edit(getUpdatingCopy(), "pom.xml", null, repository);
ScmTestCase.makeFile(getUpdatingCopy(), "/pom.xml", "changed pom.xml");
// /src/test/java/org
ScmTestCase.makeDirectory(getUpdatingCopy(), "/src/test/java/org");
addToWorkingTree(getUpdatingCopy(), new File("src/test/java/org"), repository);
// /src/main/java/org/Foo.java
ScmTestCase.makeFile(getUpdatingCopy(), "/src/main/java/org/Foo.java");
addToWorkingTree(getUpdatingCopy(), new File("src/main/java/org"), repository);
// src/main/java/org/Foo.java
addToWorkingTree(getUpdatingCopy(), new File("src/main/java/org/Foo.java"), repository);
ScmManager scmManager = getScmManager();
// ----------------------------------------------------------------------
// Check status the project
// src/main/java/org/Foo.java is added
// /pom.xml is modified
// check that readme and project.xml are not updated/created
// ----------------------------------------------------------------------
StatusScmResult result = scmManager.getProviderByUrl(getScmUrl()).status(repository, new ScmFileSet(getUpdatingCopy()));
if (this.commitUpdateCopy()) {
// this is needed for perforce so that teardown can remove its client workspace, no harm for cvs/svn/git
commit(getUpdatingCopy(), repository);
}
assertNotNull("The command returned a null result.", result);
assertResultIsSuccess(result);
List<ScmFile> changedFiles = result.getChangedFiles();
assertEquals("Expected 2 files in the updated files list " + changedFiles, 2, changedFiles.size());
// ----------------------------------------------------------------------
// Assert the files in the updated files list
// ----------------------------------------------------------------------
Iterator<ScmFile> files = new TreeSet<ScmFile>(changedFiles).iterator();
ScmFile file = files.next();
assertPath("/src/main/java/org/Foo.java", file.getPath());
assertEquals(ScmFileStatus.ADDED, file.getStatus());
file = files.next();
assertPath("/pom.xml", file.getPath());
assertEquals(ScmFileStatus.MODIFIED, file.getStatus());
assertFile(getUpdatingCopy(), "/readme.txt");
assertFalse("project.xml created incorrectly", new File(getUpdatingCopy(), "/project.xml").exists());
}
use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.
the class HgScmProvider method status.
/**
* {@inheritDoc}
*/
public StatusScmResult status(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
HgStatusCommand command = new HgStatusCommand();
command.setLogger(getLogger());
return (StatusScmResult) command.execute(repository, fileSet, parameters);
}
use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.
the class ClearCaseRemoveCommand method executeRemoveCommand.
/**
* {@inheritDoc}
*/
protected ScmResult executeRemoveCommand(ScmProviderRepository scmProviderRepository, ScmFileSet scmFileSet, String string) throws ScmException {
if (getLogger().isDebugEnabled()) {
getLogger().debug("executing remove command...");
}
Commandline cl = createCommandLine(getLogger(), scmFileSet);
ClearCaseRemoveConsumer consumer = new ClearCaseRemoveConsumer(getLogger());
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
int exitCode;
try {
// First we need to 'check out' the current directory
Commandline checkoutCurrentDirCommandLine = ClearCaseEditCommand.createCheckoutCurrentDirCommandLine(scmFileSet);
if (getLogger().isDebugEnabled()) {
getLogger().debug("Executing: " + checkoutCurrentDirCommandLine.getWorkingDirectory().getAbsolutePath() + ">>" + checkoutCurrentDirCommandLine.toString());
}
exitCode = CommandLineUtils.executeCommandLine(checkoutCurrentDirCommandLine, new CommandLineUtils.StringStreamConsumer(), stderr);
if (exitCode == 0) {
// Then we add the file
if (getLogger().isDebugEnabled()) {
getLogger().debug("Executing: " + cl.getWorkingDirectory().getAbsolutePath() + ">>" + cl.toString());
}
exitCode = CommandLineUtils.executeCommandLine(cl, consumer, stderr);
if (exitCode == 0) {
// Then we check in the current directory again.
Commandline checkinCurrentDirCommandLine = ClearCaseEditCommand.createCheckinCurrentDirCommandLine(scmFileSet);
if (getLogger().isDebugEnabled()) {
getLogger().debug("Executing: " + checkinCurrentDirCommandLine.getWorkingDirectory().getAbsolutePath() + ">>" + checkinCurrentDirCommandLine.toString());
}
exitCode = CommandLineUtils.executeCommandLine(checkinCurrentDirCommandLine, new CommandLineUtils.StringStreamConsumer(), stderr);
}
}
} catch (CommandLineException ex) {
throw new ScmException("Error while executing clearcase command.", ex);
}
if (exitCode != 0) {
return new StatusScmResult(cl.toString(), "The cleartool command failed.", stderr.getOutput(), false);
}
return new StatusScmResult(cl.toString(), consumer.getRemovedFiles());
}
use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.
the class ClearCaseUnEditCommand method executeUnEditCommand.
/**
* {@inheritDoc}
*/
protected ScmResult executeUnEditCommand(ScmProviderRepository repository, ScmFileSet fileSet) throws ScmException {
if (getLogger().isDebugEnabled()) {
getLogger().debug("executing unedit command...");
}
Commandline cl = createCommandLine(getLogger(), fileSet);
ClearCaseUnEditConsumer consumer = new ClearCaseUnEditConsumer(getLogger());
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
int exitCode;
try {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Executing: " + cl.getWorkingDirectory().getAbsolutePath() + ">>" + cl.toString());
}
exitCode = CommandLineUtils.executeCommandLine(cl, consumer, stderr);
} catch (CommandLineException ex) {
throw new ScmException("Error while executing clearcase command.", ex);
}
if (exitCode != 0) {
return new StatusScmResult(cl.toString(), "The cleartool command failed.", stderr.getOutput(), false);
}
return new StatusScmResult(cl.toString(), consumer.getUnEditFiles());
}
use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.
the class ClearCaseScmProvider method status.
/**
* {@inheritDoc}
*/
protected StatusScmResult status(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
ClearCaseStatusCommand command = new ClearCaseStatusCommand();
command.setLogger(getLogger());
return (StatusScmResult) command.execute(repository, fileSet, parameters);
}
Aggregations