use of org.apache.maven.scm.provider.accurev.CategorisedElements 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.provider.accurev.CategorisedElements in project maven-scm by apache.
the class AccuRevCommandLine method statBackingStream.
public CategorisedElements statBackingStream(File basedir, Collection<File> elements) throws AccuRevException {
CategorisedElements catElems = new CategorisedElements();
if (elements.isEmpty()) {
return catElems;
}
String[] args = { "stat", "-b", "-ffr" };
boolean ret = executeCommandLine(basedir, args, elements, new StatBackingConsumer(catElems.getMemberElements(), catElems.getNonMemberElements()));
return ret ? catElems : null;
}
use of org.apache.maven.scm.provider.accurev.CategorisedElements in project maven-scm by apache.
the class AccuRevStatusCommandTest method testStatus.
@Test
public void testStatus() throws Exception {
final ScmFileSet testFileSet = getScmFileSet();
File keptFile = new File("kept/file");
File keptAdded = new File("kept/added");
// this is the special one, it is returned by both the kept and defunct stat calls, so the command
// needs to filter it out.
File keptDefunct = new File("kept/defunct");
File modifiedFile = new File("modified/file");
File modifiedAdded = new File("modified/added");
File missingFile = new File("missing/file");
File externalFile = new File("external/file");
when(accurev.stat(eq(basedir), anyListOf(File.class), eq(AccuRevStat.DEFUNCT))).thenReturn(Arrays.asList(keptDefunct));
when(accurev.stat(eq(basedir), anyListOf(File.class), eq(AccuRevStat.MODIFIED))).thenReturn(Arrays.asList(modifiedFile, modifiedAdded));
when(accurev.stat(eq(basedir), anyListOf(File.class), eq(AccuRevStat.KEPT))).thenReturn(Arrays.asList(keptDefunct, keptFile, keptAdded));
when(accurev.stat(eq(basedir), anyListOf(File.class), eq(AccuRevStat.MISSING))).thenReturn(Arrays.asList(missingFile));
when(accurev.stat(eq(basedir), anyListOf(File.class), eq(AccuRevStat.EXTERNAL))).thenReturn(Arrays.asList(externalFile));
CategorisedElements catElems = new CategorisedElements();
catElems.getMemberElements().addAll(Arrays.asList(modifiedFile, keptFile));
catElems.getNonMemberElements().addAll(Arrays.asList(modifiedAdded, keptAdded));
when(accurev.statBackingStream(eq(basedir), (Collection<File>) argThat(hasItems(modifiedFile, modifiedAdded, keptFile, keptAdded)))).thenReturn(catElems);
AccuRevStatusCommand command = new AccuRevStatusCommand(getLogger());
CommandParameters commandParameters = new CommandParameters();
StatusScmResult result = command.status(repo, testFileSet, commandParameters);
assertThat(result.isSuccess(), is(true));
assertThat(result.getChangedFiles().size(), is(7));
assertThat((List<ScmFile>) result.getChangedFiles(), not(Matchers.<ScmFile>hasItem(scmFile("kept/defunct", ScmFileStatus.MODIFIED))));
assertHasScmFile(result.getChangedFiles(), "kept/file", ScmFileStatus.MODIFIED);
assertHasScmFile(result.getChangedFiles(), "kept/added", ScmFileStatus.ADDED);
assertHasScmFile(result.getChangedFiles(), "kept/defunct", ScmFileStatus.DELETED);
assertHasScmFile(result.getChangedFiles(), "modified/file", ScmFileStatus.MODIFIED);
assertHasScmFile(result.getChangedFiles(), "modified/added", ScmFileStatus.ADDED);
assertHasScmFile(result.getChangedFiles(), "missing/file", ScmFileStatus.MISSING);
assertHasScmFile(result.getChangedFiles(), "external/file", ScmFileStatus.UNKNOWN);
}
Aggregations