示例#1
0
  /**
   * Set the repository the formatter can load object contents from.
   *
   * <p>Once a repository has been set, the formatter must be released to ensure the internal
   * ObjectReader is able to release its resources.
   *
   * @param repository source repository holding referenced objects.
   */
  public void setRepository(Repository repository) {
    if (reader != null) reader.release();

    db = repository;
    reader = db.newObjectReader();

    ContentSource cs = ContentSource.create(reader);
    source = new ContentSource.Pair(cs, cs);

    DiffConfig dc = db.getConfig().get(DiffConfig.KEY);
    if (dc.isNoPrefix()) {
      setOldPrefix(""); // $NON-NLS-1$
      setNewPrefix(""); // $NON-NLS-1$
    }
    setDetectRenames(dc.isRenameDetectionEnabled());

    diffAlgorithm =
        DiffAlgorithm.getAlgorithm(
            db.getConfig()
                .getEnum(
                    ConfigConstants.CONFIG_DIFF_SECTION,
                    null,
                    ConfigConstants.CONFIG_KEY_ALGORITHM,
                    SupportedAlgorithm.HISTOGRAM));
  }