added modifications support to svn changesetviewer

This commit is contained in:
Sebastian Sdorra
2011-04-18 18:11:50 +02:00
parent 2c209e4161
commit 1dd3f429e5
2 changed files with 79 additions and 3 deletions

View File

@@ -40,10 +40,13 @@ import org.slf4j.LoggerFactory;
import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNLogEntry; import org.tmatesoft.svn.core.SVNLogEntry;
import org.tmatesoft.svn.core.SVNLogEntryPath;
import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.io.SVNRepository; import org.tmatesoft.svn.core.io.SVNRepository;
import org.tmatesoft.svn.core.io.SVNRepositoryFactory; import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------ //~--- JDK imports ------------------------------------------------------------
import java.io.File; import java.io.File;
@@ -51,6 +54,7 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* *
@@ -134,6 +138,35 @@ public class SvnChangesetViewer implements ChangesetViewer
//~--- methods -------------------------------------------------------------- //~--- 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 * Method description
* *
@@ -142,11 +175,25 @@ public class SvnChangesetViewer implements ChangesetViewer
* *
* @return * @return
*/ */
@SuppressWarnings("unchecked")
private Changeset createChangeset(SVNLogEntry entry) private Changeset createChangeset(SVNLogEntry entry)
{ {
return new Changeset(String.valueOf(entry.getRevision()), Changeset changeset = new Changeset(String.valueOf(entry.getRevision()),
entry.getDate().getTime(), entry.getAuthor(), entry.getDate().getTime(), entry.getAuthor(),
entry.getMessage()); entry.getMessage());
Map<String, SVNLogEntryPath> changeMap = entry.getChangedPaths();
if (Util.isNotEmpty(changeMap))
{
Modifications modifications = changeset.getModifications();
for (SVNLogEntryPath e : changeMap.values())
{
appendModification(modifications, e);
}
}
return changeset;
} }
//~--- fields --------------------------------------------------------------- //~--- fields ---------------------------------------------------------------

View File

@@ -41,6 +41,7 @@ import java.text.SimpleDateFormat;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map;
import java.util.TimeZone; import java.util.TimeZone;
/** /**
@@ -349,6 +350,20 @@ public class Util
return (collection == null) || collection.isEmpty(); return (collection == null) || collection.isEmpty();
} }
/**
* Method description
*
*
*
* @param map
*
* @return
*/
public static boolean isEmpty(Map<?, ?> map)
{
return (map == null) || map.isEmpty();
}
/** /**
* Method description * Method description
* *
@@ -404,6 +419,20 @@ public class Util
return (collection != null) &&!collection.isEmpty(); return (collection != null) &&!collection.isEmpty();
} }
/**
* Method description
*
*
*
* @param map
*
* @return
*/
public static boolean isNotEmpty(Map<?, ?> map)
{
return (map != null) &&!map.isEmpty();
}
/** /**
* Method description * Method description
* *