Class DiffCommandBuilder

java.lang.Object
sonia.scm.repository.api.DiffCommandBuilder

public final class DiffCommandBuilder extends Object
Shows differences between revisions for a specified file or the entire revision.
Note: One of the parameter path or revision have to be set.

Sample:

Print the differences from revision 33b93c443867:

 DiffCommandBuilder diff = repositoryService.getDiffCommand();
 String content = diff.setRevision("33b93c443867").getContent();
 System.out.println(content);
 
Since:
1.17
  • Method Details

    • retrieveContent

      public DiffCommandBuilder.OutputStreamConsumer retrieveContent() throws IOException
      Passes the difference of the given parameter to the outputstream.
      Returns:
      A consumer that expects the output stream for the difference
      Throws:
      IOException
    • getContent

      public String getContent() throws IOException
      Returns the content of the difference as string.
      Returns:
      content of the difference
      Throws:
      IOException
    • setFormat

      public DiffCommandBuilder setFormat(DiffFormat format)
      Sets the diff format which should be used for the output. Note: If the repository provider does not support the diff format, it will fall back to its default format.
      Parameters:
      format - format of the diff output
      Returns:
      this
      Since:
      1.34
    • setAncestorChangeset

      public DiffCommandBuilder setAncestorChangeset(String revision)
      Compute the incoming changes of the branch set with setRevision(String) in respect to the changeset given here. In other words: What changes would be new to the ancestor changeset given here when the branch would be merged into it. Requires feature Feature.INCOMING_REVISION!
      Returns:
      this
    • setPath

      public DiffCommandBuilder setPath(String path)
      Show the difference only for the given path.
      Parameters:
      path - path for difference
      Returns:
      this
    • setRevision

      public DiffCommandBuilder setRevision(String revision)
      Show the difference only for the given revision or (using setAncestorChangeset(String)) between this and another revision.
      Parameters:
      revision - revision for difference
      Returns:
      this
    • setIgnoreWhitespace

      public DiffCommandBuilder setIgnoreWhitespace(IgnoreWhitespaceLevel ignoreWhitespace)