use of org.apache.maven.scm.ScmFile in project maven-scm by apache.
the class CvsCheckoutCommandTest method assertCheckedOutFile.
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
private File assertCheckedOutFile(List<ScmFile> files, int i, String fileName, ScmFileStatus status) throws Exception {
File file = new File(getWorkingDirectory(), fileName);
assertTrue(file.getAbsolutePath() + " file doesn't exist.", file.exists());
ScmFile coFile = files.get(i);
assertSame(status, coFile.getStatus());
assertPath(fileName, coFile.getPath());
return file;
}
use of org.apache.maven.scm.ScmFile in project maven-scm by apache.
the class CvsCheckoutCommandTest method testCheckOutWithTag.
/**
* @todo move this test to the TCK - checkout with "revision", then have one for tag as well.
*/
public void testCheckOutWithTag() throws Exception {
if (!isSystemCmd(CvsScmTestUtils.CVS_COMMAND_LINE)) {
System.err.println("'" + CvsScmTestUtils.CVS_COMMAND_LINE + "' is not a system command. Ignored " + getName() + ".");
return;
}
ScmManager scmManager = getScmManager();
@SuppressWarnings("deprecation") CheckOutScmResult result = scmManager.getProviderByRepository(getScmRepository()).checkOut(getScmRepository(), getScmFileSet(), "MAVEN_1_0");
if (!result.isSuccess()) {
fail(result.getProviderMessage() + "\n" + result.getCommandOutput());
}
List<ScmFile> files = result.getCheckedOutFiles();
assertNotNull(files);
assertEquals(1, files.size());
File mavenUtils = assertCheckedOutFile(files, 0, "/src/java/org/apache/maven/MavenUtils.java", ScmFileStatus.UPDATED);
assertBetween(38403, 39511, mavenUtils.length());
}
use of org.apache.maven.scm.ScmFile in project maven-scm by apache.
the class AccuRevStatusCommand method executeAccurevCommand.
@Override
protected ScmResult executeAccurevCommand(AccuRevScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException, AccuRevException {
AccuRev accuRev = repository.getAccuRev();
File basedir = fileSet.getBasedir();
List<File> elements = fileSet.getFileList();
List<File> defunctElements = accuRev.stat(basedir, elements, AccuRevStat.DEFUNCT);
if (defunctElements == null) {
return error(accuRev, "Failed retrieving defunct elements");
}
List<File> keptElements = accuRev.stat(basedir, elements, AccuRevStat.KEPT);
// Defunct elements are also listed as kept (AccuRev 4.7.1), exclude those here.
if (keptElements == null) {
return error(accuRev, "Failed retrieving kept elements");
}
List<File> modOrAddedElements = new ArrayList<File>();
for (File file : keptElements) {
if (!defunctElements.contains(file)) {
modOrAddedElements.add(file);
}
}
List<File> modifiedElements = accuRev.stat(basedir, elements, AccuRevStat.MODIFIED);
if (modifiedElements == null) {
return error(accuRev, "Failed retrieving modified elements");
}
modOrAddedElements.addAll(modifiedElements);
CategorisedElements catElems = accuRev.statBackingStream(basedir, modOrAddedElements);
if (catElems == null) {
return error(accuRev, "Failed stat backing stream to split modified and added elements");
}
modifiedElements = catElems.getMemberElements();
List<File> addedElements;
if (AccuRevCapability.STAT_ADDED_NOT_PROMOTED_BUG.isSupported(accuRev.getClientVersion())) {
modOrAddedElements.removeAll(modifiedElements);
addedElements = modOrAddedElements;
} else {
addedElements = catElems.getNonMemberElements();
}
List<File> missingElements = accuRev.stat(basedir, elements, AccuRevStat.MISSING);
if (missingElements == null) {
return error(accuRev, "Failed retrieving missing elements");
}
List<File> externalElements = accuRev.stat(basedir, elements, AccuRevStat.EXTERNAL);
if (externalElements == null) {
return error(accuRev, "Failed retrieving external elements");
}
List<ScmFile> resultFiles = getScmFiles(defunctElements, ScmFileStatus.DELETED);
resultFiles.addAll(getScmFiles(modifiedElements, ScmFileStatus.MODIFIED));
resultFiles.addAll(getScmFiles(addedElements, ScmFileStatus.ADDED));
resultFiles.addAll(getScmFiles(missingElements, ScmFileStatus.MISSING));
resultFiles.addAll(getScmFiles(externalElements, ScmFileStatus.UNKNOWN));
return new StatusScmResult(accuRev.getCommandLines(), resultFiles);
}
use of org.apache.maven.scm.ScmFile in project maven-scm by apache.
the class AccuRevScmProvider method update.
@Override
protected UpdateScmResult update(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
AccuRevScmProviderRepository accurevRepo = (AccuRevScmProviderRepository) repository;
AccuRevUpdateCommand command = new AccuRevUpdateCommand(getLogger());
UpdateScmResult result = command.update(repository, fileSet, parameters);
if (result.isSuccess() && parameters.getBoolean(CommandParameter.RUN_CHANGELOG_WITH_UPDATE)) {
AccuRevUpdateScmResult accuRevResult = (AccuRevUpdateScmResult) result;
ScmRevision fromRevision = new ScmRevision(accuRevResult.getFromRevision());
ScmRevision toRevision = new ScmRevision(accuRevResult.getToRevision());
parameters.setScmVersion(CommandParameter.START_SCM_VERSION, fromRevision);
parameters.setScmVersion(CommandParameter.END_SCM_VERSION, toRevision);
AccuRevVersion startVersion = accurevRepo.getAccuRevVersion(fromRevision);
AccuRevVersion endVersion = accurevRepo.getAccuRevVersion(toRevision);
if (startVersion.getBasisStream().equals(endVersion.getBasisStream())) {
ChangeLogScmResult changeLogResult = changelog(repository, fileSet, parameters);
if (changeLogResult.isSuccess()) {
result.setChanges(changeLogResult.getChangeLog().getChangeSets());
} else {
getLogger().warn("Changelog from " + fromRevision + " to " + toRevision + " failed");
}
} else {
String comment = "Cross stream update result from " + startVersion + " to " + endVersion;
String author = "";
List<ScmFile> files = result.getUpdatedFiles();
List<ChangeFile> changeFiles = new ArrayList<ChangeFile>(files.size());
for (ScmFile scmFile : files) {
changeFiles.add(new ChangeFile(scmFile.getPath()));
}
ChangeSet dummyChangeSet = new ChangeSet(new Date(), comment, author, changeFiles);
// different streams invalidates the change log, insert a dummy change instead.
List<ChangeSet> changeSets = Collections.singletonList(dummyChangeSet);
result.setChanges(changeSets);
}
}
return result;
}
use of org.apache.maven.scm.ScmFile in project maven-scm by apache.
the class AbstractAccuRevExtractSourceCommand method executeAccurevCommand.
@Override
protected ScmResult executeAccurevCommand(AccuRevScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException, AccuRevException {
ScmVersion scmVersion = parameters.getScmVersion(CommandParameter.SCM_VERSION, null);
File basedir = fileSet.getBasedir();
String outputDirectory = parameters.getString(CommandParameter.OUTPUT_DIRECTORY, null);
if (outputDirectory != null) {
basedir = new File(outputDirectory);
}
if (!basedir.exists()) {
basedir.mkdirs();
}
if (!basedir.isDirectory() || basedir.list().length != 0) {
throw new ScmException("Checkout directory " + basedir.getAbsolutePath() + " not empty");
}
AccuRevVersion accuRevVersion = repository.getAccuRevVersion(scmVersion);
List<File> checkedOutFiles = extractSource(repository, basedir, accuRevVersion);
List<ScmFile> scmFiles = checkedOutFiles == null ? null : getScmFiles(checkedOutFiles, ScmFileStatus.CHECKED_OUT);
return getScmResult(repository, scmFiles, scmVersion);
}
Aggregations