Exemplo n.º 1
0
  @Override
  public List<Commit> getHistory(int page, int limit, String until)
      throws AmbiguousObjectException, IOException, NoHeadException, GitAPIException, SVNException {
    // Get the repository
    SVNURL svnURL = SVNURL.fromFile(new File(repoPrefix + ownerName + "/" + projectName));
    org.tmatesoft.svn.core.io.SVNRepository repository = SVNRepositoryFactory.create(svnURL);

    // path to get log
    String[] paths = {"/"};

    // Determine revisions
    long startRevision = repository.getLatestRevision() - page * limit;
    long endRevision = startRevision - limit;
    if (endRevision < 1) {
      endRevision = 1;
    }

    // No log to return.
    if (startRevision < endRevision) {
      return new ArrayList<>();
    }

    // Get the logs
    List<Commit> result = new ArrayList<>();
    for (Object entry : repository.log(paths, null, startRevision, endRevision, false, false)) {
      result.add(new SvnCommit((SVNLogEntry) entry));
    }

    return result;
  }
Exemplo n.º 2
0
  @Override
  public Commit getCommit(String revNumber) throws IOException, SVNException {
    long rev = Integer.parseInt(revNumber);
    String[] paths = {"/"};
    SVNURL svnURL = SVNURL.fromFile(new File(getRepoPrefix() + ownerName + "/" + projectName));
    org.tmatesoft.svn.core.io.SVNRepository repository = SVNRepositoryFactory.create(svnURL);

    for (Object entry : repository.log(paths, null, rev, rev, false, false)) {
      return new SvnCommit((SVNLogEntry) entry);
    }

    return null;
  }
Exemplo n.º 3
0
 @Override
 public boolean isEmpty() {
   SVNURL svnURL;
   org.tmatesoft.svn.core.io.SVNRepository repository = null;
   try {
     svnURL = SVNURL.fromFile(getDirectory());
     repository = SVNRepositoryFactory.create(svnURL);
     return repository.getLatestRevision() == 0;
   } catch (SVNException e) {
     throw new RuntimeException(e);
   } finally {
     if (repository != null) {
       repository.closeSession();
     }
   }
 }
Exemplo n.º 4
0
  private String getPatch(long revA, long revB) throws SVNException, UnsupportedEncodingException {
    // Prepare required arguments.
    SVNURL svnURL = SVNURL.fromFile(getDirectory());

    // Get diffClient.
    SVNClientManager clientManager = SVNClientManager.newInstance();
    SVNDiffClient diffClient = clientManager.getDiffClient();

    // Using diffClient, write the changes by commitId into
    // byteArrayOutputStream, as unified format.
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    diffClient.doDiff(
        svnURL,
        null,
        SVNRevision.create(revA),
        SVNRevision.create(revB),
        SVNDepth.INFINITY,
        true,
        byteArrayOutputStream);

    return byteArrayOutputStream.toString(Config.getCharset().name());
  }
Exemplo n.º 5
0
  @Override
  public String getPatch(String commitId) throws SVNException {
    // Prepare required arguments.
    SVNURL svnURL = SVNURL.fromFile(new File(getRepoPrefix() + ownerName + "/" + projectName));
    long rev = Integer.parseInt(commitId);

    // Get diffClient.
    SVNClientManager clientManager = SVNClientManager.newInstance();
    SVNDiffClient diffClient = clientManager.getDiffClient();

    // Using diffClient, write the changes by commitId into
    // byteArrayOutputStream, as unified format.
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    diffClient.doDiff(
        svnURL,
        null,
        SVNRevision.create(rev - 1),
        SVNRevision.create(rev),
        SVNDepth.INFINITY,
        true,
        byteArrayOutputStream);

    return byteArrayOutputStream.toString();
  }
Exemplo n.º 6
0
  private org.tmatesoft.svn.core.io.SVNRepository getSVNRepository() throws SVNException {
    SVNURL svnURL = SVNURL.fromFile(new File(getRepoPrefix() + ownerName + "/" + projectName));

    return SVNRepositoryFactory.create(svnURL);
  }
Exemplo n.º 7
0
  private org.tmatesoft.svn.core.io.SVNRepository getSVNRepository() throws SVNException {
    SVNURL svnURL = SVNURL.fromFile(getDirectory());

    return SVNRepositoryFactory.create(svnURL);
  }