use of org.apache.maven.scm.ScmFileStatus in project maven-scm by apache.
the class SvnUpdateConsumer method parseLine.
// ----------------------------------------------------------------------
// StreamConsumer Implementation
// ----------------------------------------------------------------------
/**
* {@inheritDoc}
*/
protected void parseLine(String line) {
line = line.trim();
String statusString = line.substring(0, 1);
String file = line.substring(3).trim();
// [SCM-368]
if (file.startsWith(workingDirectory.getAbsolutePath())) {
if (file.length() == workingDirectory.getAbsolutePath().length()) {
file = ".";
} else {
file = file.substring(this.workingDirectory.getAbsolutePath().length() + 1);
}
}
ScmFileStatus status;
if (line.startsWith(UPDATED_TO_REVISION_TOKEN)) {
String revisionString = line.substring(UPDATED_TO_REVISION_TOKEN.length() + 1, line.length() - 1);
revision = parseInt(revisionString);
return;
} else if (line.startsWith(AT_REVISION_TOKEN)) {
String revisionString = line.substring(AT_REVISION_TOKEN.length() + 1, line.length() - 1);
revision = parseInt(revisionString);
return;
} else if (line.startsWith(EXPORTED_REVISION_TOKEN)) {
String revisionString = line.substring(EXPORTED_REVISION_TOKEN.length() + 1, line.length() - 1);
revision = parseInt(revisionString);
return;
} else if (line.startsWith(RESTORED_TOKEN)) {
return;
} else if (statusString.equals("A")) {
status = ScmFileStatus.ADDED;
} else if (statusString.equals("U") || statusString.equals("M")) {
status = ScmFileStatus.UPDATED;
} else if (statusString.equals("D")) {
status = ScmFileStatus.DELETED;
} else {
return;
}
addFile(new ScmFile(file, status));
List<ChangeFile> changeFiles = Arrays.asList(new ChangeFile[] { new ChangeFile(line, Integer.valueOf(revision).toString()) });
ChangeSet changeSet = new ChangeSet(null, null, null, changeFiles);
changeSets.add(changeSet);
}
use of org.apache.maven.scm.ScmFileStatus in project maven-scm by apache.
the class SvnChangeLogConsumerTest method testConsumerWithPattern2.
public void testConsumerWithPattern2() throws Exception {
StringBuilder out = new StringBuilder();
File f = getTestFile("/src/test/resources/svn/changelog/svnlog2.txt");
BufferedReader r = new BufferedReader(new FileReader(f));
String line;
while ((line = r.readLine()) != null) {
consumer.consumeLine(line);
}
List modifications = consumer.getModifications();
out.append("nb modifications : " + modifications.size());
int origFileCounter = 0;
// must use *Linked* HashMap to have predictable toString
final Map<ScmFileStatus, AtomicInteger> summary = new LinkedHashMap<ScmFileStatus, AtomicInteger>();
for (ChangeSet entry : consumer.getModifications()) {
out.append("Author:" + entry.getAuthor());
out.append("Date:" + entry.getDate());
out.append("Comment:" + entry.getComment());
for (ChangeFile file : entry.getFiles()) {
final ScmFileStatus action = file.getAction();
if (!summary.containsKey(action)) {
summary.put(action, new AtomicInteger());
}
summary.get(action).incrementAndGet();
final String fileName = file.getName();
out.append("File:" + fileName);
// files in this log are known to be from one subtree
Assert.assertTrue("Unexpected file name: " + fileName, fileName.startsWith("/maven/scm/trunk"));
// files in this log are known not to contain space
Assert.assertEquals("Unexpected space found in filename: " + fileName, -1, fileName.indexOf(" "));
if (file.getOriginalName() != null) {
origFileCounter++;
}
}
out.append("==============================");
}
Assert.assertEquals("Unexpected number of file copy records", 1, origFileCounter);
Assert.assertEquals("Action summary differs from expectations", "{modified=626, deleted=56, added=310, copied=1}", summary.toString());
if (logger.isDebugEnabled()) {
logger.debug(out.toString());
}
}
use of org.apache.maven.scm.ScmFileStatus in project maven-scm by apache.
the class SvnRemoveConsumer method consumeLine.
// ----------------------------------------------------------------------
// StreamConsumer Implementation
// ----------------------------------------------------------------------
/**
* {@inheritDoc}
*/
public void consumeLine(String line) {
if (line.length() <= 3) {
if (logger.isWarnEnabled()) {
logger.warn("Unexpected input, the line must be at least three characters long. Line: '" + line + "'.");
}
return;
}
String statusString = line.substring(0, 1);
String file = line.substring(3);
ScmFileStatus status;
if (statusString.equals("D")) {
status = ScmFileStatus.DELETED;
} else {
if (logger.isInfoEnabled()) {
logger.info("Unknown file status: '" + statusString + "'.");
}
return;
}
removedFiles.add(new ScmFile(file, status));
}
use of org.apache.maven.scm.ScmFileStatus in project maven-scm by apache.
the class SvnStatusConsumer method consumeLine.
// ----------------------------------------------------------------------
// StreamConsumer Implementation
// ----------------------------------------------------------------------
/**
* {@inheritDoc}
*/
public void consumeLine(String line) {
if (logger.isDebugEnabled()) {
logger.debug(line);
}
if (StringUtils.isEmpty(line.trim())) {
return;
}
if (line.length() <= 7) {
if (logger.isWarnEnabled()) {
logger.warn("Unexpected input, the line must be at least seven characters long. Line: '" + line + "'.");
}
return;
}
String statusString = line.substring(0, 1);
String file = line.substring(7).trim();
ScmFileStatus status;
// ' ' the working copy is up to date
if (statusString.equals("A")) {
status = ScmFileStatus.ADDED;
} else if (statusString.equals("M") || statusString.equals("R") || statusString.equals("~")) {
status = ScmFileStatus.MODIFIED;
} else if (statusString.equals("D")) {
status = ScmFileStatus.DELETED;
} else if (statusString.equals("?")) {
status = ScmFileStatus.UNKNOWN;
} else if (statusString.equals("!")) {
status = ScmFileStatus.MISSING;
} else if (statusString.equals("C")) {
status = ScmFileStatus.CONFLICT;
} else if (statusString.equals("L")) {
status = ScmFileStatus.LOCKED;
} else if (statusString.equals("X")) {
// skip svn:external entries
return;
} else if (statusString.equals("I")) {
// skip svn:external entries
return;
} else {
// Parse the second column
statusString = line.substring(1, 1);
if (statusString.equals("M")) {
status = ScmFileStatus.MODIFIED;
} else if (statusString.equals("C")) {
status = ScmFileStatus.CONFLICT;
} else {
// or a status defined in next columns
return;
}
}
// If the file isn't a file; don't add it.
if (!status.equals(ScmFileStatus.DELETED) && !new File(workingDirectory, file).isFile()) {
return;
}
changedFiles.add(new ScmFile(file, status));
}
use of org.apache.maven.scm.ScmFileStatus in project maven-scm by apache.
the class SvnAddConsumer method consumeLine.
// ----------------------------------------------------------------------
// StreamConsumer Implementation
// ----------------------------------------------------------------------
/**
* {@inheritDoc}
*/
public void consumeLine(String line) {
if (line.length() <= 3) {
if (logger.isWarnEnabled()) {
logger.warn("Unexpected input, the line must be at least three characters long. Line: '" + line + "'.");
}
return;
}
String statusString = line.substring(0, 1);
String file = line.substring(3);
ScmFileStatus status;
if (statusString.equals("A")) {
status = ScmFileStatus.ADDED;
} else {
if (logger.isInfoEnabled()) {
logger.info("Unknown file status: '" + statusString + "'.");
}
return;
}
addedFiles.add(new ScmFile(file, status));
}
Aggregations