Search in sources :

Example 1 with Node

use of org.apache.commons.jrcs.rcs.Node in project OpenGrok by OpenGrok.

the class RCSHistoryParser method traverse.

private void traverse(Node n, List<HistoryEntry> history) {
    if (n == null) {
        return;
    }
    traverse(n.getChild(), history);
    TreeMap<?, ?> brt = n.getBranches();
    if (brt != null) {
        for (Iterator<?> i = brt.values().iterator(); i.hasNext(); ) {
            Node b = (Node) i.next();
            traverse(b, history);
        }
    }
    if (!n.isGhost()) {
        HistoryEntry entry = new HistoryEntry();
        entry.setRevision(n.getVersion().toString());
        entry.setDate(n.getDate());
        entry.setAuthor(n.getAuthor());
        entry.setMessage(n.getLog());
        entry.setActive(true);
        history.add(entry);
    }
}
Also used : Node(org.apache.commons.jrcs.rcs.Node)

Example 2 with Node

use of org.apache.commons.jrcs.rcs.Node in project OpenGrok by OpenGrok.

the class RCSRepository method annotate.

static Annotation annotate(File file, String revision, File rcsFile) throws IOException {
    try {
        Archive archive = new Archive(rcsFile.getPath());
        // If revision is null, use current revision
        Version version = revision == null ? archive.getRevisionVersion() : archive.getRevisionVersion(revision);
        // Get the revision with annotation
        archive.getRevision(version, true);
        Annotation a = new Annotation(file.getName());
        // considered public API anymore, but it works.
        for (Node n : archive.getRevisionNodes()) {
            String rev = n.getVersion().toString();
            String author = n.getAuthor();
            a.addLine(rev, author, true);
        }
        return a;
    } catch (ParseException pe) {
        throw wrapInIOException("Parse exception annotating RCS repository", pe);
    } catch (InvalidFileFormatException iffe) {
        throw wrapInIOException("File format exception annotating RCS repository", iffe);
    } catch (PatchFailedException pfe) {
        throw wrapInIOException("Patch failed exception annotating RCS repository", pfe);
    }
}
Also used : InvalidFileFormatException(org.apache.commons.jrcs.rcs.InvalidFileFormatException) Archive(org.apache.commons.jrcs.rcs.Archive) Version(org.apache.commons.jrcs.rcs.Version) Node(org.apache.commons.jrcs.rcs.Node) ParseException(org.apache.commons.jrcs.rcs.ParseException) PatchFailedException(org.apache.commons.jrcs.diff.PatchFailedException)

Example 3 with Node

use of org.apache.commons.jrcs.rcs.Node in project OpenGrok by OpenGrok.

the class RCSHistoryParser method parseFile.

private History parseFile(File file) throws IOException {
    try {
        Archive archive = new Archive(getRCSFile(file).getPath());
        Version ver = archive.getRevisionVersion();
        Node n = archive.findNode(ver);
        n = n.root();
        ArrayList<HistoryEntry> entries = new ArrayList<HistoryEntry>();
        traverse(n, entries);
        History history = new History();
        history.setHistoryEntries(entries);
        return history;
    } catch (ParseException pe) {
        throw RCSRepository.wrapInIOException("Could not parse file " + file.getPath(), pe);
    }
}
Also used : Archive(org.apache.commons.jrcs.rcs.Archive) Version(org.apache.commons.jrcs.rcs.Version) Node(org.apache.commons.jrcs.rcs.Node) ArrayList(java.util.ArrayList) ParseException(org.apache.commons.jrcs.rcs.ParseException)

Aggregations

Node (org.apache.commons.jrcs.rcs.Node)3 Archive (org.apache.commons.jrcs.rcs.Archive)2 ParseException (org.apache.commons.jrcs.rcs.ParseException)2 Version (org.apache.commons.jrcs.rcs.Version)2 ArrayList (java.util.ArrayList)1 PatchFailedException (org.apache.commons.jrcs.diff.PatchFailedException)1 InvalidFileFormatException (org.apache.commons.jrcs.rcs.InvalidFileFormatException)1