From 1dd3f429e59849298120ceab934ddbdfd9f7d836 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Mon, 18 Apr 2011 18:11:50 +0200 Subject: [PATCH] added modifications support to svn changesetviewer --- .../scm/repository/SvnChangesetViewer.java | 53 +++++++++++++++++-- .../src/main/java/sonia/scm/util/Util.java | 29 ++++++++++ 2 files changed, 79 insertions(+), 3 deletions(-) diff --git a/plugins/scm-svn-plugin/src/main/java/sonia/scm/repository/SvnChangesetViewer.java b/plugins/scm-svn-plugin/src/main/java/sonia/scm/repository/SvnChangesetViewer.java index d5cda52af0..a33a7d697e 100644 --- a/plugins/scm-svn-plugin/src/main/java/sonia/scm/repository/SvnChangesetViewer.java +++ b/plugins/scm-svn-plugin/src/main/java/sonia/scm/repository/SvnChangesetViewer.java @@ -40,10 +40,13 @@ import org.slf4j.LoggerFactory; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNLogEntry; +import org.tmatesoft.svn.core.SVNLogEntryPath; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.io.SVNRepository; import org.tmatesoft.svn.core.io.SVNRepositoryFactory; +import sonia.scm.util.Util; + //~--- JDK imports ------------------------------------------------------------ import java.io.File; @@ -51,6 +54,7 @@ import java.io.File; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Map; /** * @@ -134,6 +138,35 @@ public class SvnChangesetViewer implements ChangesetViewer //~--- methods -------------------------------------------------------------- + /** + * TODO: type replaced + * + * + * @param modifications + * @param entry + */ + private void appendModification(Modifications modifications, + SVNLogEntryPath entry) + { + switch (entry.getType()) + { + case SVNLogEntryPath.TYPE_ADDED : + modifications.getAdded().add(entry.getPath()); + + break; + + case SVNLogEntryPath.TYPE_DELETED : + modifications.getRemoved().add(entry.getPath()); + + break; + + case SVNLogEntryPath.TYPE_MODIFIED : + modifications.getModified().add(entry.getPath()); + + break; + } + } + /** * Method description * @@ -142,11 +175,25 @@ public class SvnChangesetViewer implements ChangesetViewer * * @return */ + @SuppressWarnings("unchecked") private Changeset createChangeset(SVNLogEntry entry) { - return new Changeset(String.valueOf(entry.getRevision()), - entry.getDate().getTime(), entry.getAuthor(), - entry.getMessage()); + Changeset changeset = new Changeset(String.valueOf(entry.getRevision()), + entry.getDate().getTime(), entry.getAuthor(), + entry.getMessage()); + Map changeMap = entry.getChangedPaths(); + + if (Util.isNotEmpty(changeMap)) + { + Modifications modifications = changeset.getModifications(); + + for (SVNLogEntryPath e : changeMap.values()) + { + appendModification(modifications, e); + } + } + + return changeset; } //~--- fields --------------------------------------------------------------- diff --git a/scm-core/src/main/java/sonia/scm/util/Util.java b/scm-core/src/main/java/sonia/scm/util/Util.java index aa9a3063dd..a4d8c9da1f 100644 --- a/scm-core/src/main/java/sonia/scm/util/Util.java +++ b/scm-core/src/main/java/sonia/scm/util/Util.java @@ -41,6 +41,7 @@ import java.text.SimpleDateFormat; import java.util.Collection; import java.util.Date; import java.util.Iterator; +import java.util.Map; import java.util.TimeZone; /** @@ -349,6 +350,20 @@ public class Util return (collection == null) || collection.isEmpty(); } + /** + * Method description + * + * + * + * @param map + * + * @return + */ + public static boolean isEmpty(Map map) + { + return (map == null) || map.isEmpty(); + } + /** * Method description * @@ -404,6 +419,20 @@ public class Util return (collection != null) &&!collection.isEmpty(); } + /** + * Method description + * + * + * + * @param map + * + * @return + */ + public static boolean isNotEmpty(Map map) + { + return (map != null) &&!map.isEmpty(); + } + /** * Method description *