use of org.apache.maven.scm.ChangeSet 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.ChangeSet in project maven-scm by apache.
the class SvnChangeLogConsumerTest method testConsumeLine_ValidOutput.
/**
* Valid svn log output should have expected values.
*
* @throws Exception if any problem occurs.
*/
public void testConsumeLine_ValidOutput() throws Exception {
final File svnLog = getTestFile("/src/test/resources/svn/changelog/svnLogValidOutput.txt");
consumeLog(svnLog);
final ChangeSet entry = consumer.getModifications().get(0);
final List changedFiles = entry.getFiles();
final String revision = ((ChangeFile) changedFiles.get(0)).getRevision();
assertEquals("Valid revision expected", "15", revision);
assertEquals("Valid num changed files expected", 2, changedFiles.size());
assertEquals("Valid name expected", "unconventional author output (somedata)", entry.getAuthor());
String expectedDate = getLocalizedDate("2002-08-26 14:33:26", TimeZone.getTimeZone("GMT-4"));
assertEquals("Valid date expected", expectedDate, entry.getDateFormatted());
assertEquals("Valid comment expected", "Minor formatting changes.\n", entry.getComment());
}
use of org.apache.maven.scm.ChangeSet in project maven-scm by apache.
the class SvnChangeLogConsumerTest method testConsumerWithPattern1.
public void testConsumerWithPattern1() throws Exception {
StringBuilder out = new StringBuilder();
File f = getTestFile("/src/test/resources/svn/changelog/svnlog.txt");
BufferedReader r = new BufferedReader(new FileReader(f));
String line;
while ((line = r.readLine()) != null) {
consumer.consumeLine(line);
}
List<ChangeSet> modifications = consumer.getModifications();
out.append("Text format:");
out.append("nb modifications : " + modifications.size());
for (ChangeSet entry : modifications) {
out.append("Author:" + entry.getAuthor());
out.append("Date:" + entry.getDate());
out.append("Comment:" + entry.getComment());
for (ChangeFile file : entry.getFiles()) {
out.append("File:" + file.getName());
}
out.append("==============================");
}
out.append("XML format:");
out.append("nb modifications : " + modifications.size());
for (ChangeSet entry : modifications) {
out.append(entry.toXML());
out.append("==============================");
}
if (logger.isDebugEnabled()) {
logger.debug(out.toString());
}
}
use of org.apache.maven.scm.ChangeSet 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.ChangeSet in project maven-scm by apache.
the class StarteamChangeLogConsumerTest method testRelativeFilePath.
public void testRelativeFilePath() throws Exception {
List<ChangeSet> entries = parseTestFile();
// ensure the filename in the first ChangeSet has correct relative path
ChangeSet entry = (ChangeSet) entries.get(1);
assertTrue(entry.containsFilename("./maven/src/File2.java"));
}
Aggregations