diff options
Diffstat (limited to 'plugins/svn4idea/src/org/jetbrains/idea/svn/history/CmdHistoryClient.java')
-rw-r--r-- | plugins/svn4idea/src/org/jetbrains/idea/svn/history/CmdHistoryClient.java | 97 |
1 files changed, 9 insertions, 88 deletions
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/CmdHistoryClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/CmdHistoryClient.java index 3494b9ac9d28..ca934d4a40e4 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/CmdHistoryClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/CmdHistoryClient.java @@ -9,19 +9,15 @@ import org.jetbrains.idea.svn.commandLine.CommandExecutor; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.jetbrains.idea.svn.commandLine.SvnCommandName; -import org.tmatesoft.svn.core.*; +import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; import javax.xml.bind.JAXBException; -import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlValue; import java.util.ArrayList; -import java.util.Date; import java.util.List; -import java.util.Map; /** * @author Konstantin Kolosovsky. @@ -37,7 +33,7 @@ public class CmdHistoryClient extends BaseSvnClient implements HistoryClient { boolean includeMergedRevisions, long limit, @Nullable String[] revisionProperties, - @Nullable ISVNLogEntryHandler handler) throws VcsException { + @Nullable LogEntryConsumer handler) throws VcsException { // TODO: add revision properties parameter if necessary List<String> parameters = @@ -54,13 +50,13 @@ public class CmdHistoryClient extends BaseSvnClient implements HistoryClient { } } - private static void parseOutput(@NotNull CommandExecutor command, @Nullable ISVNLogEntryHandler handler) + private static void parseOutput(@NotNull CommandExecutor command, @Nullable LogEntryConsumer handler) throws VcsException, SVNException { try { LogInfo log = CommandUtil.parse(command.getOutput(), LogInfo.class); if (handler != null && log != null) { - for (LogEntry entry : log.entries) { + for (LogEntry.Builder entry : log.entries) { iterateRecursively(entry, handler); } } @@ -70,16 +66,16 @@ public class CmdHistoryClient extends BaseSvnClient implements HistoryClient { } } - private static void iterateRecursively(@NotNull LogEntry entry, @NotNull ISVNLogEntryHandler handler) throws SVNException { - handler.handleLogEntry(entry.toLogEntry()); + private static void iterateRecursively(@NotNull LogEntry.Builder entry, @NotNull LogEntryConsumer handler) throws SVNException { + handler.consume(entry.build()); - for (LogEntry childEntry : entry.childEntries) { + for (LogEntry.Builder childEntry : entry.getChildEntries()) { iterateRecursively(childEntry, handler); } if (entry.hasChildren()) { // empty log entry passed to handler to fully correspond to SVNKit behavior. - handler.handleLogEntry(SVNLogEntry.EMPTY_ENTRY); + handler.consume(LogEntry.EMPTY); } } @@ -109,81 +105,6 @@ public class CmdHistoryClient extends BaseSvnClient implements HistoryClient { public static class LogInfo { @XmlElement(name = "logentry") - public List<LogEntry> entries = new ArrayList<LogEntry>(); - } - - public static class LogEntry { - - @XmlAttribute(name = "revision") - public long revision; - - @XmlElement(name = "author") - public String author; - - @XmlElement(name = "date") - public Date date; - - @XmlElement(name = "msg") - public String message; - - @XmlElement(name = "paths") - public ChangedPaths changedPaths; - - @XmlElement(name = "logentry") - public List<LogEntry> childEntries = new ArrayList<LogEntry>(); - - public boolean hasChildren() { - return !childEntries.isEmpty(); - } - - public SVNLogEntry toLogEntry() { - SVNLogEntry entry = new SVNLogEntry(toChangedPathsMap(), revision, author, date, message); - - entry.setHasChildren(hasChildren()); - - return entry; - } - - public Map<String, SVNLogEntryPath> toChangedPathsMap() { - return changedPaths != null ? changedPaths.toMap() : ContainerUtil.<String, SVNLogEntryPath>newHashMap(); - } - } - - public static class ChangedPaths { - - @XmlElement(name = "path") - public List<ChangedPath> changedPaths = new ArrayList<ChangedPath>(); - - public Map<String, SVNLogEntryPath> toMap() { - Map<String, SVNLogEntryPath> changes = ContainerUtil.newHashMap(); - - for (ChangedPath path : changedPaths) { - changes.put(path.path, path.toLogEntryPath()); - } - - return changes; - } - } - - public static class ChangedPath { - - @XmlAttribute(name = "kind") - public String kind; - - @XmlAttribute(name = "action") - public String action; - - @XmlAttribute(name = "copyfrom-path") - public String copyFromPath; - - @XmlAttribute(name = "copyfrom-rev") - public long copyFromRevision; - - @XmlValue - public String path; - - public SVNLogEntryPath toLogEntryPath() { - return new SVNLogEntryPath(path, CommandUtil.getStatusChar(action), copyFromPath, copyFromRevision); - } + public List<LogEntry.Builder> entries = ContainerUtil.newArrayList(); } } |