Пример #1
0
  public static long scanFullRepository(
      ScanRepository scanRepository,
      String url,
      long fromRev,
      String indexDirectory,
      boolean create,
      ISVNAuthenticationManager authManager,
      Filtering filtering)
      throws SVNException {
    Repository repository = new Repository(url, authManager);

    boolean firstTime = true;

    // Assuming we have fromRev: 1
    // toRev: HEAD (-1)
    long latestRevision = repository.getRepository().getLatestRevision();

    // Define number per round
    long deltaRevisions = 10000;
    long blockNumber = 0;

    for (long revisions = fromRev; revisions < latestRevision; revisions += deltaRevisions) {
      long startRevision = revisions;
      long endRevision = revisions + deltaRevisions - 1;
      if (endRevision > latestRevision) {
        endRevision = latestRevision;
      }

      blockNumber = revisions / deltaRevisions;

      // BLOCK BEGIN
      if (create) {
        if (firstTime) {
          firstTime = false;
        } else {
          create = false;
        }
      }

      scanRepository.setLogEntries(new ArrayList<SVNLogEntry>());
      scanRepository.setRepository(repository);

      // We start with the revision which is given on the command line.
      // If it is not given we will start with revision 1.
      scanRepository.setStartRevision(startRevision);
      // We will scan the repository to the current HEAD of the repository.
      scanRepository.setEndRevision(endRevision);

      scanRepository.setFiltering(filtering);

      ScanSingleRepository.scanSingleRepos(scanRepository, indexDirectory + blockNumber, create);
      // BLOCK END
    }
    return blockNumber;
  }
Пример #2
0
 @Override
 public void indexDocument(
     Repository repository, SVNDirEntry dirEntry, String path, long revision) {
   LOGGER.debug("Scanning archive document");
   try {
     ByteArrayOutputStream baos = new ByteArrayOutputStream();
     // This means we get the contents of the file only. No properties.
     repository.getRepository().getFile(path, revision, null, baos);
     ByteArrayInputStream str = new ByteArrayInputStream(baos.toByteArray());
     scan(str, path, dirEntry);
   } catch (SVNException e) {
     LOGGER.error("Exception by SVN: ", e);
   } catch (Exception e) {
     LOGGER.error("We had an exception " + path + " (r" + dirEntry.getRevision() + ")", e);
   }
 }