use of org.apache.maven.scm.command.update.UpdateScmResult in project maven-scm by apache.
the class VssScmProvider method update.
/**
* {@inheritDoc}
*/
public UpdateScmResult update(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
VssUpdateCommand command = new VssUpdateCommand();
command.setLogger(getLogger());
return (UpdateScmResult) command.execute(repository, fileSet, parameters);
}
use of org.apache.maven.scm.command.update.UpdateScmResult in project maven-scm by apache.
the class MavenScmCli method update.
private void update(ScmRepository scmRepository, File workingDirectory, ScmVersion version) throws ScmException {
if (!workingDirectory.exists()) {
System.err.println("The working directory doesn't exist: '" + workingDirectory.getAbsolutePath() + "'.");
return;
}
UpdateScmResult result = scmManager.update(scmRepository, new ScmFileSet(workingDirectory), version);
if (!result.isSuccess()) {
showError(result);
return;
}
List<ScmFile> updatedFiles = result.getUpdatedFiles();
System.out.println("Updated these files: ");
for (ScmFile file : updatedFiles) {
System.out.println(" " + file.getPath());
}
}
use of org.apache.maven.scm.command.update.UpdateScmResult in project maven-scm by apache.
the class JazzUpdateCommand method executeUpdateCommand.
/**
* {@inheritDoc}
*/
protected UpdateScmResult executeUpdateCommand(ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion version) throws ScmException {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Executing update command...");
}
JazzUpdateConsumer updateConsumer = new JazzUpdateConsumer(repo, getLogger());
ErrorConsumer errConsumer = new ErrorConsumer(getLogger());
JazzScmCommand updateCmd = createAcceptCommand(repo, fileSet);
int status = updateCmd.execute(updateConsumer, errConsumer);
if (status != 0) {
return new UpdateScmResult(updateCmd.getCommandString(), "Error code for Jazz SCM update command - " + status, errConsumer.getOutput(), false);
}
if (getLogger().isDebugEnabled()) {
if (!updateConsumer.getUpdatedFiles().isEmpty()) {
getLogger().debug("Iterating over \"Update\" results");
for (ScmFile file : updateConsumer.getUpdatedFiles()) {
getLogger().debug(file.getPath() + " : " + file.getStatus());
}
} else {
getLogger().debug("There are no updated files");
}
}
// We can use the checkout directory for this.
return new UpdateScmResult(updateCmd.getCommandString(), updateConsumer.getUpdatedFiles());
}
use of org.apache.maven.scm.command.update.UpdateScmResult in project maven-scm by apache.
the class JazzScmProvider method update.
/**
* {@inheritDoc}
*/
protected UpdateScmResult update(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
getLogger().debug("JazzScmProvider:update()");
JazzUpdateCommand command = new JazzUpdateCommand();
command.setLogger(getLogger());
return (UpdateScmResult) command.execute(repository, fileSet, parameters);
}
use of org.apache.maven.scm.command.update.UpdateScmResult in project maven-scm by apache.
the class UpdateCommandTckTest method testUpdateCommand.
public void testUpdateCommand() throws Exception {
deleteDirectory(getUpdatingCopy());
assertFalse(getUpdatingCopy().exists());
// deleteDirectory( getWorkingCopy() );
// assertFalse( getUpdatingCopy().exists() );
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)
* src/test/resources is untouched (a empty directory is left untouched)
* src/test/java is untouched (a non empty directory is left untouched)
* src/test/java/org (a empty directory is added)
* src/main/java/org/Foo.java (a non empty directory is added)
*/
// /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());
// /src/test/java/org
ScmTestCase.makeDirectory(getWorkingCopy(), "/src/test/java/org");
addToWorkingTree(getWorkingCopy(), new File("src/test/java/org"), getScmRepository());
// /src/main/java/org/Foo.java
ScmTestCase.makeFile(getWorkingCopy(), "/src/main/java/org/Foo.java");
addToWorkingTree(getWorkingCopy(), new File("src/main/java/org"), getScmRepository());
// src/main/java/org/Foo.java
addToWorkingTree(getWorkingCopy(), new File("src/main/java/org/Foo.java"), getScmRepository());
ScmManager scmManager = getScmManager();
Date lastUpdate = new Date(System.currentTimeMillis() - 1000000);
commit(getWorkingCopy(), getScmRepository());
Thread.sleep(5000);
// ----------------------------------------------------------------------
// Update the project
// ----------------------------------------------------------------------
UpdateScmResult result = scmManager.update(repository, new ScmFileSet(getUpdatingCopy()), lastUpdate);
assertNotNull("The command returned a null result.", result);
assertResultIsSuccess(result);
List<ScmFile> updatedFiles = result.getUpdatedFiles();
List<ChangeSet> changedSets = result.getChanges();
assertEquals("Expected 3 files in the updated files list " + updatedFiles, 3, updatedFiles.size());
assertNotNull("The changed files list is null", changedSets);
assertFalse("The changed files list is empty ", changedSets.isEmpty());
for (ChangeSet changeSet : changedSets) {
System.out.println(changeSet.toXML());
}
// ----------------------------------------------------------------------
// Assert the files in the updated files list
// ----------------------------------------------------------------------
Iterator<ScmFile> files = new TreeSet<ScmFile>(updatedFiles).iterator();
// Foo.java
ScmFile file = files.next();
assertPath("/src/main/java/org/Foo.java", file.getPath());
// TODO : Consolidate file status so that we can remove "|| ADDED" term
assertTrue(file.getStatus().isUpdate() || file.getStatus() == ScmFileStatus.ADDED);
// readme.txt
file = files.next();
assertPath("/readme.txt", file.getPath());
assertTrue(file.getStatus().isUpdate());
// project.xml
file = files.next();
assertPath("/project.xml", file.getPath());
// TODO : Consolidate file status so that we can remove "|| ADDED" term
assertTrue(file.getStatus().isUpdate() || file.getStatus() == ScmFileStatus.ADDED);
}
Aggregations