Class SvnDiffUtils

java.lang.Object
net.sf.statsvn.util.SvnDiffUtils
All Implemented Interfaces:
ISvnDiffProcessor
Direct Known Subclasses:
SvnKitDiff

public class SvnDiffUtils extends Object implements ISvnDiffProcessor
Utilities class that manages calls to svn diff.
Version:
$Id: SvnDiffUtils.java 394 2009-08-10 20:08:46Z jkealey $
Author:
Jason Kealey invalid input: '<'jkealey@shade.ca>, Gunter Mussbacher invalid input: '<'gunterm@site.uottawa.ca>
  • Field Details

  • Constructor Details

    • SvnDiffUtils

      public SvnDiffUtils(ISvnProcessor processor)
      Invokes diffs using the svn diff command line.
  • Method Details

    • getProcessor

      protected ISvnProcessor getProcessor()
    • callSvnDiff

      protected ProcessUtils callSvnDiff(String oldRevNr, String newRevNr, String filename) throws IOException
      Calls svn diff for the filename and revisions given. Will use URL invocation, to ensure that we get diffs even for deleted files.
      Parameters:
      oldRevNr - old revision number
      newRevNr - new revision number
      filename - filename.
      Returns:
      the InputStream related to the call. If the error steam is non-empty, will return the error stream instead of the default input stream.
      Throws:
      IOException
    • callSvnDiff

      protected ProcessUtils callSvnDiff(String newRevNr) throws IOException
      Calls svn diff on all files for given revision and revision-1.
      Parameters:
      newRevNr - revision number
      Returns:
      the InputStream related to the call. If the error steam is non-empty, will return the error stream instead of the default input stream.
      Throws:
      IOException
    • getLineDiff

      public int[] getLineDiff(String oldRevNr, String newRevNr, String filename) throws IOException, BinaryDiffException
      Description copied from interface: ISvnDiffProcessor
      Returns line count differences between two revisions of a file.
      Specified by:
      getLineDiff in interface ISvnDiffProcessor
      Parameters:
      oldRevNr - old revision number
      newRevNr - new revision number
      filename - the filename
      Returns:
      A int[2] array of [lines added, lines removed] is returned.
      Throws:
      IOException - problem parsing the stream
      BinaryDiffException - if the error message is due to trying to diff binary files.
    • parseSingleDiffStream

      protected int[] parseSingleDiffStream(InputStream diffStream) throws IOException, BinaryDiffException
      Throws:
      IOException
      BinaryDiffException
    • verifyOutput

      protected void verifyOutput(ProcessUtils pUtils) throws IOException, BinaryDiffException
      Verifies the process error stream.
      Parameters:
      pUtils - the process call
      Throws:
      IOException - problem parsing the stream
      BinaryDiffException - if the error message is due to trying to diff binary files.
    • getLineDiff

      public Vector getLineDiff(String newRevNr) throws IOException, BinaryDiffException
      Description copied from interface: ISvnDiffProcessor
      Returns line count differences for all files in a particular revision.
      Specified by:
      getLineDiff in interface ISvnDiffProcessor
      Parameters:
      newRevNr - new revision number
      Returns:
      A vector of object[3] array of [filename, int[2](lines added, lines removed), isBinary] is returned.
      Throws:
      IOException - problem parsing the stream
      BinaryDiffException - if the error message is due to trying to diff binary files.
    • parseMultipleDiffStream

      protected void parseMultipleDiffStream(Vector answer, InputStream diffStream) throws IOException
      Throws:
      IOException
    • appendResults

      protected void appendResults(Vector answer, String currFile, StringBuffer sb) throws IOException
      Append results to answer vector.
      Parameters:
      answer - the current answers
      currFile - the current file being added.
      sb - the diff for this individual file.
      Throws:
      IOException - problem parsing the stream
      BinaryDiffException - if the error message is due to trying to diff binary files.
    • isBinaryErrorMessage

      protected boolean isBinaryErrorMessage(String msg)
      Returns true if msg is an error message display that the file is binary.
      Parameters:
      msg - the error message given by ProcessUtils.getErrorMessage();
      Returns:
      true if the file is binary
    • parseDiff

      protected int[] parseDiff(net.sf.statcvs.util.LookaheadReader diffReader) throws IOException, BinaryDiffException
      Returns line count differences between two revisions of a file.
      Parameters:
      diffReader - the stream reader for svn diff
      Returns:
      A int[2] array of [lines added, lines removed] is returned.
      Throws:
      IOException - problem parsing the stream
      BinaryDiffException