use of org.apache.maven.scm.command.update.UpdateScmResult in project maven-scm by apache.
the class StarteamScmProvider method update.
/**
* {@inheritDoc}
*/
public UpdateScmResult update(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
fileSet = fixUpScmFileSetAbsoluteFilePath(fileSet);
StarteamUpdateCommand command = new StarteamUpdateCommand();
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 SynergyUpdateCommand method executeUpdateCommand.
/**
* {@inheritDoc}
*/
protected UpdateScmResult executeUpdateCommand(ScmProviderRepository repository, ScmFileSet fileSet, ScmVersion version) throws ScmException {
if (getLogger().isDebugEnabled()) {
getLogger().debug("executing update command...");
}
SynergyScmProviderRepository repo = (SynergyScmProviderRepository) repository;
if (getLogger().isDebugEnabled()) {
getLogger().debug("basedir: " + fileSet.getBasedir());
}
String ccmAddr = SynergyUtil.start(getLogger(), repo.getUser(), repo.getPassword(), null);
File waPath;
try {
String projectSpec = SynergyUtil.getWorkingProject(getLogger(), repo.getProjectSpec(), repo.getUser(), ccmAddr);
SynergyUtil.reconfigureProperties(getLogger(), projectSpec, ccmAddr);
SynergyUtil.reconfigure(getLogger(), projectSpec, ccmAddr);
// We need to get WA path
waPath = SynergyUtil.getWorkArea(getLogger(), projectSpec, ccmAddr);
} finally {
SynergyUtil.stop(getLogger(), ccmAddr);
}
File source = new File(waPath, repo.getProjectName());
// Move file from work area to expected dir if not the same
List<ScmFile> modifications = new ArrayList<ScmFile>();
if (!source.equals(fileSet.getBasedir())) {
if (getLogger().isInfoEnabled()) {
getLogger().info("We will copy modified files from Synergy Work Area [" + source + "] to expected folder [" + fileSet.getBasedir() + "]");
}
try {
copyDirectoryStructure(source, fileSet.getBasedir(), modifications);
} catch (IOException e1) {
throw new ScmException("Unable to copy directory structure", e1);
}
}
return new UpdateScmResult("ccm reconcile -uwa ...", modifications);
}
use of org.apache.maven.scm.command.update.UpdateScmResult in project maven-scm by apache.
the class AccurevUpdateCommandTest method testUpdate.
@Test
public void testUpdate() throws Exception {
final File keptFile = new File("updated/file");
final File keptAdded = new File("new/file");
List<File> files = Arrays.asList(keptFile, keptAdded);
when(accurev.update(eq(basedir), any(String.class))).thenReturn(files);
AccuRevUpdateCommand command = new AccuRevUpdateCommand(getLogger());
CommandParameters commandParameters = new CommandParameters();
commandParameters.setString(CommandParameter.RUN_CHANGELOG_WITH_UPDATE, Boolean.toString(false));
UpdateScmResult result = command.update(repo, testFileSet, commandParameters);
assertThat(result.isSuccess(), is(true));
assertThat(result.getUpdatedFiles().size(), is(2));
assertHasScmFile(result.getUpdatedFiles(), "updated/file", ScmFileStatus.UPDATED);
assertHasScmFile(result.getUpdatedFiles(), "new/file", ScmFileStatus.UPDATED);
}
use of org.apache.maven.scm.command.update.UpdateScmResult in project maven-scm by apache.
the class AccurevUpdateCommandTest method testUpdateWithChangeLog.
@Test
public void testUpdateWithChangeLog() throws Exception {
final WorkSpace wsBefore = new WorkSpace("theWorkSpace", 123);
Map<String, WorkSpace> workspaces = Collections.singletonMap("theWorkSpace", wsBefore);
when(accurev.showWorkSpaces()).thenReturn(workspaces);
List<File> emptyList = Collections.emptyList();
when(accurev.update(eq(basedir), any(String.class))).thenReturn(emptyList);
final Date currentDate = new Date();
List<Transaction> transactions = Collections.singletonList(new Transaction(197L, currentDate, "type", "user"));
when(accurev.history(any(String.class), any(String.class), any(String.class), eq(1), eq(true), eq(true))).thenReturn(transactions);
AccuRevUpdateCommand command = new AccuRevUpdateCommand(getLogger());
CommandParameters commandParameters = new CommandParameters();
commandParameters.setString(CommandParameter.RUN_CHANGELOG_WITH_UPDATE, Boolean.toString(true));
UpdateScmResult result = command.update(repo, testFileSet, commandParameters);
assertThat(result.isSuccess(), is(true));
assertThat(result, IsInstanceOf.instanceOf(AccuRevUpdateScmResult.class));
AccuRevUpdateScmResult accuRevResult = (AccuRevUpdateScmResult) result;
assertThat(accuRevResult.getFromRevision(), is("theWorkSpace/123"));
assertThat(accuRevResult.getToRevision(), is("theWorkSpace/197"));
}
use of org.apache.maven.scm.command.update.UpdateScmResult in project maven-scm by apache.
the class BazaarUpdateCommand method executeUpdateCommand.
/**
* {@inheritDoc}
*/
protected UpdateScmResult executeUpdateCommand(ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion version) throws ScmException {
if (version != null && StringUtils.isNotEmpty(version.getName())) {
throw new ScmException("This provider can't handle tags.");
}
File workingDir = fileSet.getBasedir();
// Update branch
String[] updateCmd = new String[] { BazaarConstants.PULL_CMD };
ScmResult updateResult = BazaarUtils.execute(new BazaarConsumer(getLogger()), getLogger(), workingDir, updateCmd);
if (!updateResult.isSuccess()) {
return new UpdateScmResult(null, null, updateResult);
}
// Find changes from last revision
int currentRevision = BazaarUtils.getCurrentRevisionNumber(getLogger(), workingDir);
int previousRevision = currentRevision - 1;
String[] diffCmd = new String[] { BazaarConstants.DIFF_CMD, BazaarConstants.REVISION_OPTION, "" + previousRevision };
BazaarDiffConsumer diffConsumer = new BazaarDiffConsumer(getLogger(), workingDir);
ScmResult diffResult = BazaarUtils.execute(diffConsumer, getLogger(), workingDir, diffCmd);
// Now translate between diff and update file status
List<ScmFile> updatedFiles = new ArrayList<ScmFile>();
List<CharSequence> changes = new ArrayList<CharSequence>();
List<ScmFile> diffFiles = diffConsumer.getChangedFiles();
Map<String, CharSequence> diffChanges = diffConsumer.getDifferences();
for (Iterator<ScmFile> it = diffFiles.iterator(); it.hasNext(); ) {
ScmFile file = it.next();
changes.add(diffChanges.get(file));
if (file.getStatus() == ScmFileStatus.MODIFIED) {
updatedFiles.add(new ScmFile(file.getPath(), ScmFileStatus.PATCHED));
} else {
updatedFiles.add(file);
}
}
return new UpdateScmResultWithRevision(updatedFiles, new ArrayList<ChangeSet>(0), String.valueOf(currentRevision), diffResult);
}
Aggregations