Search in sources :

Example 16 with ChangeSet

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]);
}
Also used : ChangeFile(org.apache.maven.scm.ChangeFile) ChangeSet(org.apache.maven.scm.ChangeSet)

Example 17 with ChangeSet

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));
}
Also used : ChangeLogSet(org.apache.maven.scm.command.changelog.ChangeLogSet) ArrayList(java.util.ArrayList) TfsChangeLogConsumer(org.apache.maven.scm.provider.tfs.command.consumer.TfsChangeLogConsumer) ChangeLogScmResult(org.apache.maven.scm.command.changelog.ChangeLogScmResult) ChangeSet(org.apache.maven.scm.ChangeSet) File(java.io.File) ErrorStreamConsumer(org.apache.maven.scm.provider.tfs.command.consumer.ErrorStreamConsumer)

Example 18 with ChangeSet

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);
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) DefaultLog(org.apache.maven.scm.log.DefaultLog) BufferedReader(java.io.BufferedReader) ChangeSet(org.apache.maven.scm.ChangeSet) FileInputStream(java.io.FileInputStream)

Example 19 with ChangeSet

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 = "";
    }
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) ChangeFile(org.apache.maven.scm.ChangeFile) ArrayList(java.util.ArrayList) ParseException(java.text.ParseException) ChangeSet(org.apache.maven.scm.ChangeSet) Date(java.util.Date)

Example 20 with ChangeSet

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();
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) ChangeSet(org.apache.maven.scm.ChangeSet)

Aggregations

ChangeSet (org.apache.maven.scm.ChangeSet)62 ChangeFile (org.apache.maven.scm.ChangeFile)34 ArrayList (java.util.ArrayList)21 Date (java.util.Date)18 ChangeLogSet (org.apache.maven.scm.command.changelog.ChangeLogSet)16 File (java.io.File)15 ChangeLogScmResult (org.apache.maven.scm.command.changelog.ChangeLogScmResult)15 Matcher (java.util.regex.Matcher)8 ScmException (org.apache.maven.scm.ScmException)8 BufferedReader (java.io.BufferedReader)7 SimpleDateFormat (java.text.SimpleDateFormat)7 ScmFile (org.apache.maven.scm.ScmFile)6 ScmFileSet (org.apache.maven.scm.ScmFileSet)5 ScmResult (org.apache.maven.scm.ScmResult)5 DefaultLog (org.apache.maven.scm.log.DefaultLog)5 FileReader (java.io.FileReader)4 List (java.util.List)4 ScmFileStatus (org.apache.maven.scm.ScmFileStatus)4 FileInputStream (java.io.FileInputStream)3 InputStreamReader (java.io.InputStreamReader)3