use of org.apache.maven.scm.command.add.AddScmResult in project maven-scm by apache.
the class CvsExeAddCommand method executeCvsCommand.
/**
* {@inheritDoc}
*/
protected AddScmResult executeCvsCommand(Commandline cl, List<ScmFile> addedFiles) throws ScmException {
CommandLineUtils.StringStreamConsumer consumer = new CommandLineUtils.StringStreamConsumer();
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
int exitCode;
try {
exitCode = CommandLineUtils.executeCommandLine(cl, consumer, stderr);
} catch (CommandLineException ex) {
throw new ScmException("Error while executing command.", ex);
}
// TODO: actually it may have partially succeeded - should we cvs update the files and parse "A " responses?
if (exitCode != 0) {
return new AddScmResult(cl.toString(), "The cvs command failed.", stderr.getOutput(), false);
}
return new AddScmResult(cl.toString(), addedFiles);
}
use of org.apache.maven.scm.command.add.AddScmResult in project maven-scm by apache.
the class CheckInCommandTckTest method testCheckInCommandTest.
public void testCheckInCommandTest() throws Exception {
// Make sure that the correct files was checked out
File fooJava = new File(getWorkingCopy(), "src/main/java/Foo.java");
File barJava = new File(getWorkingCopy(), "src/main/java/Bar.java");
File readmeTxt = new File(getWorkingCopy(), "readme.txt");
assertFalse("check Foo.java doesn't yet exist", fooJava.canRead());
assertFalse("check Bar.java doesn't yet exist", barJava.canRead());
assertTrue("check can read readme.txt", readmeTxt.canRead());
// Change the files
createFooJava(fooJava);
createBarJava(barJava);
changeReadmeTxt(readmeTxt);
AddScmResult addResult = getScmManager().add(getScmRepository(), new ScmFileSet(getWorkingCopy(), "src/main/java/Foo.java", null));
assertResultIsSuccess(addResult);
CheckInScmResult result = getScmManager().checkIn(getScmRepository(), new ScmFileSet(getWorkingCopy()), "Commit message");
assertResultIsSuccess(result);
List<ScmFile> files = result.getCheckedInFiles();
assertNotNull(files);
assertEquals(2, files.size());
Map<String, ScmFile> fileMap = mapFilesByPath(files);
ScmFile file1 = fileMap.get("src/main/java/Foo.java");
assertNotNull(file1);
assertEquals(ScmFileStatus.CHECKED_IN, file1.getStatus());
ScmFile file2 = fileMap.get("readme.txt");
assertNotNull(file2);
assertEquals(ScmFileStatus.CHECKED_IN, file2.getStatus());
CheckOutScmResult checkoutResult = getScmManager().checkOut(getScmRepository(), new ScmFileSet(getAssertionCopy()));
assertResultIsSuccess(checkoutResult);
fooJava = new File(getAssertionCopy(), "src/main/java/Foo.java");
barJava = new File(getAssertionCopy(), "src/main/java/Bar.java");
readmeTxt = new File(getAssertionCopy(), "readme.txt");
assertTrue("check can read Foo.java", fooJava.canRead());
assertFalse("check Bar.java doesn't exist", barJava.canRead());
assertTrue("check can read readme.txt", readmeTxt.canRead());
assertEquals("check readme.txt contents", "changed file", FileUtils.fileRead(readmeTxt));
}
use of org.apache.maven.scm.command.add.AddScmResult in project maven-scm by apache.
the class HgScmProvider method add.
/**
* {@inheritDoc}
*/
public AddScmResult add(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
HgAddCommand command = new HgAddCommand();
command.setLogger(getLogger());
return (AddScmResult) command.execute(repository, fileSet, parameters);
}
use of org.apache.maven.scm.command.add.AddScmResult in project maven-scm by apache.
the class HgAddCommand method executeAddCommand.
/**
* {@inheritDoc}
*/
protected ScmResult executeAddCommand(ScmProviderRepository repo, ScmFileSet fileSet, String message, boolean binary) throws ScmException {
// String[] addCmd = new String[] { ADD_CMD, NO_RECURSE_OPTION };
String[] addCmd = new String[] { HgCommandConstants.ADD_CMD, HgCommandConstants.VERBOSE_OPTION };
addCmd = HgUtils.expandCommandLine(addCmd, fileSet);
File workingDir = fileSet.getBasedir();
HgAddConsumer consumer = new HgAddConsumer(getLogger(), workingDir);
ScmResult result = HgUtils.execute(consumer, getLogger(), workingDir, addCmd);
AddScmResult addScmResult = new AddScmResult(consumer.getAddedFiles(), result);
// framework seems to think that this is the way we should behave. it's pretty hacky. -rwd
for (File workingFile : fileSet.getFileList()) {
File file = new File(workingDir + "/" + workingFile.getPath());
if (file.isDirectory() && file.listFiles().length == 0) {
addScmResult.getAddedFiles().add(new ScmFile(workingFile.getPath(), ScmFileStatus.ADDED));
}
}
return addScmResult;
}
use of org.apache.maven.scm.command.add.AddScmResult in project maven-scm by apache.
the class IntegrityAddCommand method executeAddCommand.
/**
* {@inheritDoc}
*/
@Override
public AddScmResult executeAddCommand(ScmProviderRepository repository, ScmFileSet fileSet, String message, boolean binary) throws ScmException {
getLogger().info("Attempting to add new files from directory " + fileSet.getBasedir().getAbsolutePath());
IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
Sandbox siSandbox = iRepo.getSandbox();
String excludes = Sandbox.formatFilePatterns(fileSet.getExcludes());
String includes = Sandbox.formatFilePatterns(fileSet.getIncludes());
String msg = ((null == message || message.length() == 0) ? System.getProperty("message") : message);
List<ScmFile> addedFiles = siSandbox.addNonMembers(excludes, includes, msg);
if (siSandbox.getOverallAddSuccess()) {
return new AddScmResult("si add", addedFiles);
} else {
return new AddScmResult(addedFiles, new ScmResult("si add", "There was a problem adding files to the repository", "", false));
}
}
Aggregations