public ArrayList<SVNCommit> getAllRevisions() {
    if (latestRevision < 1l) return revisions;
    try {
      final Collection<SVNLogEntry> logEntries =
          repository.log(
              new String[] {""}, null, lastSeenRevision + 1l, latestRevision, true, true);

      for (final SVNLogEntry logEntry : logEntries) {
        final SVNCommit revision = new SVNCommit(repository, this, logEntry);

        revision.setId("" + logEntry.getRevision());
        if (logEntry.getAuthor() == null) revision.setCommitter(logEntry.getAuthor());
        else revision.setCommitter("anonymous");
        revision.setDate(logEntry.getDate());
        revision.setMessage(logEntry.getMessage());

        if (logEntry.getChangedPaths() != null && logEntry.getChangedPaths().size() > 0) {
          final HashMap<String, String> rChangedPaths = new HashMap<String, String>();
          final HashMap<String, String> rRemovedPaths = new HashMap<String, String>();
          final HashMap<String, String> rAddedPaths = new HashMap<String, String>();
          for (final Iterator changedPaths = logEntry.getChangedPaths().keySet().iterator();
              changedPaths.hasNext(); ) {
            final SVNLogEntryPath entryPath =
                (SVNLogEntryPath) logEntry.getChangedPaths().get(changedPaths.next());
            if (repository.checkPath(entryPath.getPath(), logEntry.getRevision())
                == SVNNodeKind.FILE) {
              if (entryPath.getType() == SVNLogEntryPath.TYPE_DELETED)
                rRemovedPaths.put(entryPath.getPath(), entryPath.getCopyPath());
              else if (entryPath.getType() == SVNLogEntryPath.TYPE_ADDED)
                rAddedPaths.put(entryPath.getPath(), entryPath.getCopyPath());
              else rChangedPaths.put(entryPath.getPath(), entryPath.getCopyPath());
            }
          }
          revision.setChangedPaths(rChangedPaths);
          revision.setRemovedPaths(rRemovedPaths);
          revision.setAddedPaths(rAddedPaths);
        }

        this.revisions.add(revision);
      }
    } catch (final SVNException e) {
      e.printStackTrace();
    }
    return revisions;
  }
 protected SvnFileRevision createRevision(final SVNLogEntry logEntry, final String copyPath)
     throws SVNException {
   Date date = logEntry.getDate();
   String author = logEntry.getAuthor();
   String message = logEntry.getMessage();
   SVNRevision rev = SVNRevision.create(logEntry.getRevision());
   final SVNURL url = myRepositoryRoot.appendPath(myLastPath, true);
   return new SvnFileRevision(
       myVcs, myPegRevision, rev, url.toString(), author, date, message, copyPath, myCharset);
 }
 public void testGetAndAdd() throws Exception {
   final ObjectCache cache = createMemoryCache();
   final RevisionCacheImpl revisionCache = new RevisionCacheImpl(cache);
   try {
     assertNull(revisionCache.get(123));
     revisionCache.add(TestUtils.getLogEntryStub());
     final SVNLogEntry result = revisionCache.get(123);
     assertNotNull(result);
     assertEquals(123, result.getRevision());
     assertEquals("TestAuthor", result.getAuthor());
     assertNotNull(result.getDate());
     assertEquals("TestMessage", result.getMessage());
   } finally {
     cache.shutdown();
   }
 }
  public void getCommits(SVNLogEntry svnlogEntry) {
    this.type = "SVN";
    this.date = Calendar.getInstance();
    if (svnlogEntry.getDate() != null) this.date.setTime(svnlogEntry.getDate());
    this.author = svnlogEntry.getAuthor();
    this.message = svnlogEntry.getMessage();
    if (this.message != null) this.message = this.message.replace(",", ".").replace("\n", "|");
    this.revision = svnlogEntry.getRevision();

    Map myChangedPaths = svnlogEntry.getChangedPaths();

    if (myChangedPaths != null && !myChangedPaths.isEmpty()) {
      for (Iterator paths = myChangedPaths.values().iterator(); paths.hasNext(); ) {
        SVNLogEntryPath path = (SVNLogEntryPath) paths.next();
        getDiff(this.revision, path.getPath(), path.getType(), 0);
      }
    }
    System.out.println("");
  }
 static ChangeInfo classifiedChange(final SVNLogEntry entry, String rootPath, final String path) {
   StoreKind kind = StoreKind.OTHER;
   // Be sure the root path ends with a slash because the 'path' will always have the slash.
   if (!rootPath.endsWith("/")) {
     rootPath = rootPath + "/";
   }
   String name = path.length() > rootPath.length() ? path.substring(rootPath.length()) : path;
   String page = null;
   Matcher matcher = PAGE_PATH.matcher(name);
   if (matcher.matches() && !name.endsWith("-attachments")) {
     kind = StoreKind.PAGE;
     page = name;
   } else {
     matcher = ATTACHMENT_PATH.matcher(name);
     if (matcher.matches()) {
       kind = StoreKind.ATTACHMENT;
       page = matcher.group(1);
       name = matcher.group(2);
     }
   }
   String user = entry.getAuthor();
   Date date = entry.getDate();
   SVNLogEntryPath logForPath = (SVNLogEntryPath) entry.getChangedPaths().get(path);
   String copiedFrom = logForPath.getCopyPath();
   long copiedFromRevision = -1;
   if (SVNPathUtil.isAncestor(rootPath, copiedFrom)) {
     copiedFrom = SVNPathUtil.tail(copiedFrom);
     copiedFromRevision = logForPath.getCopyRevision();
   } else {
     copiedFrom = null;
   }
   return new ChangeInfo(
       page,
       name,
       user,
       date,
       entry.getRevision(),
       entry.getMessage(),
       kind,
       ChangeType.forCode(logForPath.getType()),
       copiedFrom,
       copiedFromRevision);
 }
  @Override
  public void handleLogEntry(SVNLogEntry logEntry) throws SVNException {
    Map<String, SVNLogEntryPath> map = logEntry.getChangedPaths();

    if (map != null && map.size() > 0) {
      getDBUtil()
          .insertIntoRevision(
              logEntry.getRevision(),
              logEntry.getAuthor(),
              sdfdb.format(logEntry.getDate()),
              logEntry.getMessage());
      for (String key : map.keySet()) {
        SVNLogEntryPath entry = map.get(key);
        if (isNeedStore(key)) {
          getDBUtil()
              .insertIntoFileInfo(
                  entry.getPath(),
                  logEntry.getRevision(),
                  getType(entry.getType()),
                  entry.getCopyPath());
        }
      }
    }
  }
  // unfortunately, the original method is private, so we need to copy / paste it
  // copied from SVNXMLLogHandler
  //
  protected void sendToHandler(SVNLogEntry logEntry) throws SAXException {
    if (logEntry.getRevision() == 0 && logEntry.getMessage() == null) {
      return;
    }
    addAttribute(REVISION_ATTR, logEntry.getRevision() + "");
    openTag(LOGENTRY_TAG);
    if (logEntry.getAuthor() != null) {
      addTag(AUTHOR_TAG, logEntry.getAuthor());
    }
    if (logEntry.getDate() != null && logEntry.getDate().getTime() != 0) {
      addTag(DATE_TAG, SVNDate.formatDate(logEntry.getDate()));
    }
    if (logEntry.getChangedPaths() != null && !logEntry.getChangedPaths().isEmpty()) {
      openTag(PATHS_TAG);
      for (Iterator<String> paths = logEntry.getChangedPaths().keySet().iterator();
          paths.hasNext(); ) {
        String key = paths.next();
        SVNLogEntryPath path = (SVNLogEntryPath) logEntry.getChangedPaths().get(key);
        addAttribute(ACTION_ATTR, path.getType() + "");
        if (path.getCopyPath() != null) {
          addAttribute(COPYFROM_PATH_ATTR, path.getCopyPath());
          addAttribute(COPYFROM_REV_ATTR, path.getCopyRevision() + "");
        }
        if (path.getKind() != null) {
          addAttribute(KIND_ATTR, path.getKind().toString());
        }
        addTag(PATH_TAG, path.getPath());
      }
      closeTag(PATHS_TAG);
    }

    if (!myIsOmitLogMessage) {
      String message = logEntry.getMessage();
      message = message == null ? "" : message;
      addTag(MSG_TAG, message);
    }

    if (myMergeStack != null && !myMergeStack.isEmpty()) {
      MergeFrame frame = (MergeFrame) myMergeStack.getLast();
      frame.myNumberOfChildrenRemaining--;
    }

    if (logEntry.hasChildren()) {
      MergeFrame frame = new MergeFrame();
      if (myMergeStack == null) {
        myMergeStack = new LinkedList<MergeFrame>();
      }
      myMergeStack.addLast(frame);
    } else {
      while (myMergeStack != null && !myMergeStack.isEmpty()) {
        MergeFrame frame = (MergeFrame) myMergeStack.getLast();
        if (frame.myNumberOfChildrenRemaining == 0) {
          closeTag(LOGENTRY_TAG);
          myMergeStack.removeLast();
        } else {
          break;
        }
      }
      closeTag(LOGENTRY_TAG);
    }
  }
  @Override
  protected String getChangeFileNames(String lastFinishDateTimeString) throws Exception {
    /*
     * Default values:
     */
    String url = Globals.getProperty("svn.url");
    String name = Globals.getProperty("svn.user");
    String password = Globals.getProperty("svn.password");

    long startRevision = 0;
    long endRevision = -1; // HEAD (the latest) revision

    setupLibrary();

    SVNRepository repository = null;

    try {
      repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(url));
    } catch (SVNException svne) {
      /*
       * Perhaps a malformed URL is the cause of this exception.
       */
      System.err.println(
          "error while creating an SVNRepository for the location '"
              + url
              + "': "
              + svne.getMessage());
      System.exit(1);
    }

    ISVNAuthenticationManager authManager =
        SVNWCUtil.createDefaultAuthenticationManager(name, password);
    repository.setAuthenticationManager(authManager);

    /*
     * Gets the latest revision number of the repository
     */
    try {
      endRevision = repository.getLatestRevision();
      startRevision = endRevision;
    } catch (SVNException svne) {
      System.err.println(
          "error while fetching the latest repository revision: " + svne.getMessage());
      System.exit(1);
    }

    Collection logEntries = null;
    try {
      /*
       * Collects SVNLogEntry objects for all revisions in the range
       * defined by its start and end points [startRevision, endRevision].
       * For each revision commit information is represented by
       * SVNLogEntry.
       *
       * the 1st parameter (targetPaths - an array of path strings) is set
       * when restricting the [startRevision, endRevision] range to only
       * those revisions when the paths in targetPaths were changed.
       *
       * the 2nd parameter if non-null - is a user's Collection that will
       * be filled up with found SVNLogEntry objects; it's just another
       * way to reach the scope.
       *
       * startRevision, endRevision - to define a range of revisions you are
       * interested in; by default in this program - startRevision=0, endRevision=
       * the latest (HEAD) revision of the repository.
       *
       * the 5th parameter - a boolean flag changedPath - if true then for
       * each revision a corresponding SVNLogEntry will contain a map of
       * all paths which were changed in that revision.
       *
       * the 6th parameter - a boolean flag strictNode - if false and a
       * changed path is a copy (branch) of an existing one in the repository
       * then the history for its origin will be traversed; it means the
       * history of changes of the target URL (and all that there's in that
       * URL) will include the history of the origin path(s).
       * Otherwise if strictNode is true then the origin path history won't be
       * included.
       *
       * The return value is a Collection filled up with SVNLogEntry Objects.
       */
      logEntries = repository.log(new String[] {""}, null, startRevision, endRevision, true, true);

    } catch (SVNException svne) {
      System.out.println(
          "error while collecting log information for '" + url + "': " + svne.getMessage());
      System.exit(1);
    }
    for (Iterator entries = logEntries.iterator(); entries.hasNext(); ) {
      /*
       * gets a next SVNLogEntry
       */
      SVNLogEntry logEntry = (SVNLogEntry) entries.next();
      System.out.println("---------------------------------------------");
      /*
       * gets the revision number
       */
      System.out.println("revision: " + logEntry.getRevision());
      /*
       * gets the author of the changes made in that revision
       */
      System.out.println("author: " + logEntry.getAuthor());
      /*
       * gets the time moment when the changes were committed
       */
      System.out.println("date: " + logEntry.getDate());
      /*
       * gets the commit log message
       */
      System.out.println("log message: " + logEntry.getMessage());
      /*
       * displaying all paths that were changed in that revision; cahnged
       * path information is represented by SVNLogEntryPath.
       */
      if (logEntry.getChangedPaths().size() > 0) {
        System.out.println();
        System.out.println("changed paths:");
        /*
         * keys are changed paths
         */
        Set changedPathsSet = logEntry.getChangedPaths().keySet();

        for (Iterator changedPaths = changedPathsSet.iterator(); changedPaths.hasNext(); ) {
          /*
           * obtains a next SVNLogEntryPath
           */
          SVNLogEntryPath entryPath =
              (SVNLogEntryPath) logEntry.getChangedPaths().get(changedPaths.next());
          /*
           * SVNLogEntryPath.getPath returns the changed path itself;
           *
           * SVNLogEntryPath.getType returns a charecter describing
           * how the path was changed ('A' - added, 'D' - deleted or
           * 'M' - modified);
           *
           * If the path was copied from another one (branched) then
           * SVNLogEntryPath.getCopyPath &
           * SVNLogEntryPath.getCopyRevision tells where it was copied
           * from and what revision the origin path was at.
           */
          System.out.println(
              " "
                  + entryPath.getType()
                  + "	"
                  + entryPath.getPath()
                  + ((entryPath.getCopyPath() != null)
                      ? " (from "
                          + entryPath.getCopyPath()
                          + " revision "
                          + entryPath.getCopyRevision()
                          + ")"
                      : ""));
        }
      }
    }
    return "";
  }