diff options
Diffstat (limited to 'plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/CmdAnnotateClient.java')
-rw-r--r-- | plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/CmdAnnotateClient.java | 86 |
1 files changed, 14 insertions, 72 deletions
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/CmdAnnotateClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/CmdAnnotateClient.java index 5cb18a35fc5c..b48f14a41779 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/CmdAnnotateClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/CmdAnnotateClient.java @@ -4,12 +4,12 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.checkin.CommitInfo; import org.jetbrains.idea.svn.commandLine.CommandExecutor; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnCommandName; +import org.jetbrains.idea.svn.diff.DiffOptions; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNAnnotateHandler; -import org.tmatesoft.svn.core.wc.SVNDiffOptions; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -18,7 +18,6 @@ import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import java.util.ArrayList; -import java.util.Date; import java.util.List; /** @@ -32,8 +31,8 @@ public class CmdAnnotateClient extends BaseSvnClient implements AnnotateClient { @NotNull SVNRevision endRevision, @Nullable SVNRevision pegRevision, boolean includeMergedRevisions, - @Nullable SVNDiffOptions diffOptions, - @Nullable final ISVNAnnotateHandler handler) throws VcsException { + @Nullable DiffOptions diffOptions, + @Nullable final AnnotationConsumer handler) throws VcsException { List<String> parameters = new ArrayList<String>(); CommandUtil.put(parameters, target.getPathOrUrlString(), pegRevision); parameters.add("--revision"); @@ -47,7 +46,7 @@ public class CmdAnnotateClient extends BaseSvnClient implements AnnotateClient { parseOutput(command.getOutput(), handler); } - public void parseOutput(@NotNull String output, @Nullable ISVNAnnotateHandler handler) throws VcsException { + public void parseOutput(@NotNull String output, @Nullable AnnotationConsumer handler) throws VcsException { try { BlameInfo info = CommandUtil.parse(output, BlameInfo.class); @@ -65,12 +64,11 @@ public class CmdAnnotateClient extends BaseSvnClient implements AnnotateClient { } } - private static void invokeHandler(ISVNAnnotateHandler handler, LineEntry entry) throws SVNException { - // line numbers in our api start from 0 - not from 1 like in svn output - // "line" value is not used in handlers - so null is passed - handler - .handleLine(entry.date(), entry.revision(), entry.author(), null, entry.mergedDate(), entry.mergedRevision(), entry.mergedAuthor(), - entry.mergedPath(), entry.lineNumber - 1); + private static void invokeHandler(@NotNull AnnotationConsumer handler, @NotNull LineEntry entry) throws SVNException { + if (entry.commit != null) { + // line numbers in our api start from 0 - not from 1 like in svn output + handler.consume(entry.lineNumber - 1, entry.commit.build(), entry.mergedCommit()); + } } @XmlRootElement(name = "blame") @@ -91,70 +89,15 @@ public class CmdAnnotateClient extends BaseSvnClient implements AnnotateClient { @XmlAttribute(name = "line-number") public int lineNumber; - @XmlElement(name = "commit") - public CommitEntry commit; + public CommitInfo.Builder commit; @XmlElement(name = "merged") public MergedEntry merged; - public long revision() { - return revision(commit); - } - - @Nullable - public String author() { - return author(commit); - } - - @Nullable - public Date date() { - return date(commit); - } - - @Nullable - public String mergedPath() { - return merged != null ? merged.path : null; - } - - public long mergedRevision() { - return merged != null ? revision(merged.commit) : 0; - } - - @Nullable - public String mergedAuthor() { - return merged != null ? author(merged.commit) : null; - } - - @Nullable - public Date mergedDate() { - return merged != null ? date(merged.commit) : null; - } - - private static long revision(@Nullable CommitEntry commit) { - return commit != null ? commit.revision : 0; - } - @Nullable - private static String author(@Nullable CommitEntry commit) { - return commit != null ? commit.author : null; + public CommitInfo mergedCommit() { + return merged != null && merged.commit != null ? merged.commit.build() : null; } - - @Nullable - private static Date date(@Nullable CommitEntry commit) { - return commit != null ? commit.date : null; - } - } - - public static class CommitEntry { - - @XmlAttribute(name = "revision") - public long revision; - - @XmlElement(name = "author") - public String author; - - @XmlElement(name = "date") - public Date date; } public static class MergedEntry { @@ -162,7 +105,6 @@ public class CmdAnnotateClient extends BaseSvnClient implements AnnotateClient { @XmlAttribute(name = "path") public String path; - @XmlElement(name = "commit") - public CommitEntry commit; + public CommitInfo.Builder commit; } } |