use of org.apache.maven.scm.ChangeSet in project maven-scm by apache.
the class VssChangeLogConsumer method processGetFile.
/**
* Process the current input line in the Get File state.
*
* @param line a line of text from the VSS log output
*/
private void processGetFile(String line) {
currentChangeSet = (new ChangeSet());
String[] fileLine = line.split(" ");
currentFile = new ChangeFile(fileLine[2]);
}
use of org.apache.maven.scm.ChangeSet in project maven-scm by apache.
the class TfsChangeLogCommand method executeChangeLogCommand.
protected ChangeLogScmResult executeChangeLogCommand(ScmProviderRepository r, ScmFileSet f, Date startDate, Date endDate, ScmBranch branch, String datePattern) throws ScmException {
List<ChangeSet> changeLogs = new ArrayList<ChangeSet>();
Iterator<File> iter = f.getFileList().iterator();
if (!iter.hasNext()) {
List<File> dir = new ArrayList<File>();
// No files to iterate
dir.add(f.getBasedir());
iter = dir.iterator();
}
TfsCommand command = null;
// tf history takes only one file arg
while (iter.hasNext()) {
TfsChangeLogConsumer out = new TfsChangeLogConsumer(getLogger());
ErrorStreamConsumer err = new ErrorStreamConsumer();
command = createCommand(r, f, ((File) iter.next()));
int status = command.execute(out, err);
if (status != 0 || (!out.hasBeenFed() && err.hasBeenFed())) {
return new ChangeLogScmResult(command.getCommandString(), "Error code for TFS changelog command - " + status, err.getOutput(), false);
}
changeLogs.addAll(out.getLogs());
}
return new ChangeLogScmResult(command.getCommandString(), new ChangeLogSet(changeLogs, startDate, endDate));
}
use of org.apache.maven.scm.ChangeSet in project maven-scm by apache.
the class CvsChangeLogConsumerTest method testParse.
/**
* Test of parse method
*
* @throws Exception when there is an unexpected problem
*/
public void testParse() throws Exception {
CvsChangeLogConsumer command = new CvsChangeLogConsumer(new DefaultLog(), null);
FileInputStream fis = new FileInputStream(testFile);
BufferedReader in = new BufferedReader(new InputStreamReader(fis));
String s = in.readLine();
while (s != null) {
command.consumeLine(s);
s = in.readLine();
}
Collection<ChangeSet> entries = command.getModifications();
assertEquals("Wrong number of entries returned", 3, entries.size());
ChangeSet entry = null;
for (Iterator<ChangeSet> i = entries.iterator(); i.hasNext(); ) {
entry = i.next();
assertTrue("ChangeLogEntry erroneously picked up", entry.toString().indexOf("ChangeLogEntry.java") == -1);
}
}
use of org.apache.maven.scm.ChangeSet in project maven-scm by apache.
the class TfsChangeLogConsumer method addChangeLog.
private void addChangeLog() {
if (!buffer.equals("")) {
Pattern p = Pattern.compile(PATTERN);
Matcher m = p.matcher(buffer);
if (m.find()) {
String revision = m.group(1).trim();
String username = m.group(2).trim();
String dateString = m.group(3).trim();
String comment = m.group(4).trim();
Pattern itemPattern = Pattern.compile(PATTERN_ITEM);
Matcher itemMatcher = itemPattern.matcher(m.group(5));
List<ChangeFile> files = new ArrayList<ChangeFile>();
while (itemMatcher.find()) {
ChangeFile file = new ChangeFile(itemMatcher.group(2).trim(), revision);
files.add(file);
}
Date date;
try {
date = parseDate(dateString);
} catch (ParseException e) {
getLogger().error("Date parse error", e);
throw new RuntimeException(e);
}
ChangeSet change = new ChangeSet(date, comment, username, files);
logs.add(change);
}
buffer = "";
}
}
use of org.apache.maven.scm.ChangeSet in project maven-scm by apache.
the class ChangeLogSet method toXML.
/**
* Creates an XML representation of this change log set.
*/
public String toXML(String encoding) {
String encodingString = encoding;
if (encodingString == null) {
encodingString = DEFAULT_ENCODING;
}
StringBuilder buffer = new StringBuilder();
String pattern = "yyyyMMdd HH:mm:ss z";
SimpleDateFormat formatter = new SimpleDateFormat(pattern);
buffer.append("<?xml version=\"1.0\" encoding=\"" + encodingString + "\"?>\n");
buffer.append("<changeset datePattern=\"").append(pattern).append("\"");
if (startDate != null) {
buffer.append(" start=\"").append(formatter.format(getStartDate())).append("\"");
}
if (endDate != null) {
buffer.append(" end=\"").append(formatter.format(getEndDate())).append("\"");
}
if (startVersion != null) {
buffer.append(" startVersion=\"").append(getStartVersion()).append("\"");
}
if (endVersion != null) {
buffer.append(" endVersion=\"").append(getEndVersion()).append("\"");
}
buffer.append(">\n");
// Write out the entries
for (ChangeSet changeSet : getChangeSets()) {
buffer.append(changeSet.toXML());
}
buffer.append("</changeset>\n");
return buffer.toString();
}
Aggregations