use of org.apache.maven.scm.ScmFile in project maven-scm by apache.
the class ClearCaseRemoveConsumer method consumeLine.
// ----------------------------------------------------------------------
// Stream Consumer Implementation
// ----------------------------------------------------------------------
/**
* {@inheritDoc}
*/
public void consumeLine(String line) {
if (logger.isDebugEnabled()) {
logger.debug(line);
}
int beginIndex = line.indexOf('"');
if (beginIndex != -1) {
String fileName = line.substring(beginIndex + 1, line.indexOf('"', beginIndex + 1));
removedFiles.add(new ScmFile(fileName, ScmFileStatus.DELETED));
}
}
use of org.apache.maven.scm.ScmFile in project maven-scm by apache.
the class AbstractCvsAddCommand method executeAddCommand.
/**
* {@inheritDoc}
*/
protected ScmResult executeAddCommand(ScmProviderRepository repo, ScmFileSet fileSet, String message, boolean binary) throws ScmException {
CvsScmProviderRepository repository = (CvsScmProviderRepository) repo;
Commandline cl = CvsCommandUtils.getBaseCommand("add", repository, fileSet);
if (binary) {
cl.createArg().setValue("-kb");
}
if (message != null && message.length() > 0) {
cl.createArg().setValue("-m");
cl.createArg().setValue("\"" + message + "\"");
}
List<ScmFile> addedFiles = new ArrayList<ScmFile>(fileSet.getFileList().size());
for (File file : fileSet.getFileList()) {
String path = file.getPath().replace('\\', '/');
cl.createArg().setValue(path);
addedFiles.add(new ScmFile(path, ScmFileStatus.ADDED));
}
if (getLogger().isInfoEnabled()) {
getLogger().info("Executing: " + cl);
getLogger().info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath());
}
return executeCvsCommand(cl, addedFiles);
}
use of org.apache.maven.scm.ScmFile in project maven-scm by apache.
the class CvsCheckInConsumer method consumeLine.
// ----------------------------------------------------------------------
// StreamConsumer Implementation
// ----------------------------------------------------------------------
/**
* {@inheritDoc}
*/
public void consumeLine(String line) {
if (logger.isDebugEnabled()) {
logger.debug(line);
}
int end = line.indexOf(",v <-- ");
if (end == -1) {
return;
}
String fileName = line.substring(0, end);
if (!fileName.startsWith(remotePath)) {
return;
}
fileName = fileName.substring(remotePath.length());
checkedInFiles.add(new ScmFile(fileName, ScmFileStatus.CHECKED_IN));
}
use of org.apache.maven.scm.ScmFile in project maven-scm by apache.
the class CvsCheckOutConsumer method consumeLine.
/**
* {@inheritDoc}
*/
public void consumeLine(String line) {
if (logger.isDebugEnabled()) {
logger.debug(line);
}
if (line.length() < 3) {
if (StringUtils.isNotEmpty(line)) {
if (logger.isWarnEnabled()) {
logger.warn("Unable to parse output from command: line length must be bigger than 3. (" + line + ").");
}
}
return;
}
String status = line.substring(0, 2);
String file = line.substring(2);
file = file.substring(file.indexOf('/'));
if (status.equals("U ")) {
files.add(new ScmFile(file, ScmFileStatus.UPDATED));
} else if (status.equals("P ")) {
files.add(new ScmFile(file, ScmFileStatus.PATCHED));
} else if (status.equals("C ")) {
files.add(new ScmFile(file, ScmFileStatus.CONFLICT));
} else {
if (logger.isWarnEnabled()) {
logger.warn("Unknown status: '" + status + "'.");
}
}
}
use of org.apache.maven.scm.ScmFile in project maven-scm by apache.
the class CvsDiffConsumer method consumeLine.
// ----------------------------------------------------------------------
// StreamConsumer Implementation
// ----------------------------------------------------------------------
/**
* {@inheritDoc}
*/
public void consumeLine(String line) {
if (logger.isDebugEnabled()) {
logger.debug(line);
}
if (line.startsWith(INDEX_TOKEN)) {
// start a new file
currentFile = line.substring(INDEX_TOKEN.length());
changedFiles.add(new ScmFile(currentFile, ScmFileStatus.MODIFIED));
currentDifference = new StringBuilder();
differences.put(currentFile, currentDifference);
patch.append(line).append("\n");
return;
}
if (currentFile == null) {
if (logger.isWarnEnabled()) {
logger.warn("Unparseable line: '" + line + "'");
}
patch.append(line).append("\n");
return;
}
if (line.startsWith(FILE_SEPARATOR_TOKEN)) {
// skip
patch.append(line).append("\n");
} else if (line.startsWith(START_REVISION_TOKEN)) {
// skip, though could parse to verify filename, start revision
patch.append(line).append("\n");
} else if (line.startsWith(END_REVISION_TOKEN)) {
// skip, though could parse to verify filename, end revision
patch.append(line).append("\n");
} else if (line.startsWith(RCS_TOKEN)) {
// skip, though could parse to verify filename
} else if (line.startsWith(RETRIEVING_TOKEN)) {
// skip, though could parse to verify version
} else if (line.startsWith(DIFF_TOKEN)) {
// skip, though could parse to verify command
} else if (line.startsWith(ADDED_LINE_TOKEN) || line.startsWith(REMOVED_LINE_TOKEN) || line.startsWith(UNCHANGED_LINE_TOKEN) || line.startsWith(CHANGE_SEPARATOR_TOKEN) || line.equals(NO_NEWLINE_TOKEN)) {
// add to buffer
currentDifference.append(line).append("\n");
patch.append(line).append("\n");
} else {
if (logger.isWarnEnabled()) {
logger.warn("Unparseable line: '" + line + "'");
}
patch.append(line).append("\n");
// skip to next file
currentFile = null;
currentDifference = null;
}
}
Aggregations