Example usage for org.apache.commons.jrcs.rcs Archive getRevisionVersion

List of usage examples for org.apache.commons.jrcs.rcs Archive getRevisionVersion

Introduction

In this page you can find the example usage for org.apache.commons.jrcs.rcs Archive getRevisionVersion.

Prototype

public Version getRevisionVersion() 

Source Link

Document

Return the actual revision number of the active revision.

Usage

From source file:org.opensolaris.opengrok.history.RCSHistoryParser.java

private History parseFile(File file) throws IOException {
    try {//from  www.j ava2  s .co  m
        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);
    }
}

From source file:org.opensolaris.opengrok.history.RCSRepository.java

static Annotation annotate(File file, String revision, File rcsFile) throws IOException {
    try {//from w  w  w  .  j  av  a2  s.co m
        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());
        // A comment in Archive.getRevisionNodes() says that it is not
        // 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);
    }
}