Class LogCommandBuilder

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

public final class LogCommandBuilder extends Object
LogCommandBuilder is able to show the history of a file in a Repository or the entire history of a Repository. This class could be used to retrieve a single Changeset by its id or to get a list of changesets in a ChangesetPagingResult which can be used for paging.

Samples:

Retrieve a single Changeset:

 LogCommandBuilder log = repositoryService.getLogCommand();
 Changeset changeset = log.getChangeset("id-of-the-commit");
 
Retrieve changesets of a Repository with paging:

 LogCommandBuilder log = repositoryService.getLogCommand();
 ChangesetPagingResult changesetPagingResult =
          log.setPagingStart(25).setPagingLimit(25).getChangesets();
 
Retrieve all changesets of a file in a Repository:

 LogCommandBuilder log = repositoryService.getLogCommand();
 ChangesetPagingResult changesetPagingResult =
          log.setPath("pom.xml").disablePagingLimit().getChangesets();
 
Since:
1.17
  • Method Details

    • disablePagingLimit

      public LogCommandBuilder disablePagingLimit()
      Disable paging limit all available changesets will be retrieved. This method does the same as setPagingLimit(int) with a value of -1.
      Returns:
      this
    • reset

      public LogCommandBuilder reset()
      Reset each parameter to its default value.
      Returns:
      this
    • getChangeset

      public Changeset getChangeset(String id) throws IOException
      Returns the Changeset with the given id or null if the Changeset could not be found in the Repository.
      Parameters:
      id - id of the Changeset
      Returns:
      the Changeset with the given id or null
      Throws:
      IOException
    • getChangesets

      public ChangesetPagingResult getChangesets() throws IOException
      Return all changesets with the given parameters.
      Returns:
      all changesets with the given parameters
      Throws:
      IOException
    • setBranch

      public LogCommandBuilder setBranch(String branch)
      Retrieves only changesets of the given branch.
      Note: This option is ignored if the underlying RepositoryService does not support the Command.BRANCHES.
      Parameters:
      branch - brnach to retrieve changesets from
      Returns:
      retrieves only changesets of the given branch
    • setDisableCache

      public LogCommandBuilder setDisableCache(boolean disableCache)
      Disables the cache for changesets. This means that every Changeset is directly retrieved from the Repository. Note: Disabling the cache cost a lot of performance and could be much more slower.
      Parameters:
      disableCache - true to disable the cache
      Returns:
      this
    • setDisablePreProcessors

      public LogCommandBuilder setDisablePreProcessors(boolean disablePreProcessors)
      Disable the execution of pre processors if set to true.
    • setEndChangeset

      public LogCommandBuilder setEndChangeset(String endChangeset)
      Retrieve changesets until the given the Changeset with the given id.
      Parameters:
      endChangeset - id of the end Changeset
      Returns:
      this
    • setPagingLimit

      public LogCommandBuilder setPagingLimit(int pagingLimit)
      Set the limit for the returned changesets. The default value is 20. Setting the value to -1 means to disable the limit.
      Parameters:
      pagingLimit - limit for returned changesets
      Returns:
      this
    • setPagingStart

      public LogCommandBuilder setPagingStart(int pagingStart)
      Sets the start value for paging. The value is 0.
      Parameters:
      pagingStart - start value for paging
      Returns:
      this
    • setPath

      public LogCommandBuilder setPath(String path)
      Retrieve only changesets which are affect the given path.
      Parameters:
      path - file path in the Repository.
      Returns:
      this
    • setStartChangeset

      public LogCommandBuilder setStartChangeset(String startChangeset)
      Start at the given Changeset.
      Parameters:
      startChangeset - changeset id to start with
      Returns:
      this
    • setAncestorChangeset

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