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

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

Introduction

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

Prototype

public Object[] getRevision(Version vernum)
        throws InvalidFileFormatException, PatchFailedException, NodeNotFoundException 

Source Link

Document

Get the text belonging to the revision identified by the given version number.

Usage

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

/**
 * Pass null in version to get current revision
 */// w w  w . j ava  2s  .  c o m
public RCSget(String file, String version) throws IOException, FileNotFoundException {
    try {
        Archive archive = new Archive(file);
        Object[] lines;

        if (version == null) {
            lines = archive.getRevision(false);
        } else {
            lines = archive.getRevision(version, false);
        }

        StringBuilder sb = new StringBuilder();
        for (int ii = 0; ii < lines.length; ++ii) {
            sb.append((String) lines[ii]);
            sb.append("\n");
        }
        stream = new ByteArrayInputStream(sb.toString().getBytes());
    } catch (ParseException e) {
        throw RCSRepository.wrapInIOException("Parse error", e);
    } catch (InvalidFileFormatException e) {
        throw RCSRepository.wrapInIOException("Invalid RCS file format", e);
    } catch (PatchFailedException e) {
        throw RCSRepository.wrapInIOException("Patch failed", e);
    } catch (NodeNotFoundException e) {
        throw RCSRepository.wrapInIOException("Revision " + version + " not found", e);
    }
}