List of usage examples for org.apache.commons.jrcs.rcs Archive Archive
public Archive(String path) throws ParseException, FileNotFoundException
From source file:org.opensolaris.opengrok.history.RCSget.java
/** * Pass null in version to get current revision *//*from www.j a va 2s . c om*/ 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); } }
From source file:org.opensolaris.opengrok.history.RCSHistoryParser.java
private History parseFile(File file) throws IOException { try {//from w w w .j av a 2 s . c o 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 {//w w w. ja va 2 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); } }