summaryrefslogtreecommitdiff
path: root/plugins/svn4idea/src/org/jetbrains/idea/svn/browse
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/svn4idea/src/org/jetbrains/idea/svn/browse')
-rw-r--r--plugins/svn4idea/src/org/jetbrains/idea/svn/browse/BrowseClient.java5
-rw-r--r--plugins/svn4idea/src/org/jetbrains/idea/svn/browse/CmdBrowseClient.java87
-rw-r--r--plugins/svn4idea/src/org/jetbrains/idea/svn/browse/DirectoryEntry.java100
-rw-r--r--plugins/svn4idea/src/org/jetbrains/idea/svn/browse/DirectoryEntryConsumer.java25
-rw-r--r--plugins/svn4idea/src/org/jetbrains/idea/svn/browse/SvnKitBrowseClient.java19
5 files changed, 156 insertions, 80 deletions
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/BrowseClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/BrowseClient.java
index 92e64bb5230e..f5c46cb32842 100644
--- a/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/BrowseClient.java
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/BrowseClient.java
@@ -18,9 +18,8 @@ package org.jetbrains.idea.svn.browse;
import com.intellij.openapi.vcs.VcsException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.idea.svn.api.Depth;
import org.jetbrains.idea.svn.api.SvnClient;
-import org.tmatesoft.svn.core.ISVNDirEntryHandler;
-import org.tmatesoft.svn.core.SVNDepth;
import org.tmatesoft.svn.core.wc.SVNRevision;
import org.tmatesoft.svn.core.wc2.SvnTarget;
@@ -29,7 +28,7 @@ import org.tmatesoft.svn.core.wc2.SvnTarget;
*/
public interface BrowseClient extends SvnClient {
- void list(@NotNull SvnTarget target, @Nullable SVNRevision revision, @Nullable SVNDepth depth, @Nullable ISVNDirEntryHandler handler)
+ void list(@NotNull SvnTarget target, @Nullable SVNRevision revision, @Nullable Depth depth, @Nullable DirectoryEntryConsumer handler)
throws VcsException;
long createDirectory(@NotNull SvnTarget target, @NotNull String message, boolean makeParents) throws VcsException;
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/CmdBrowseClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/CmdBrowseClient.java
index 20d60a9e50bf..bceb516caef3 100644
--- a/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/CmdBrowseClient.java
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/CmdBrowseClient.java
@@ -21,12 +21,17 @@ import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.svn.api.BaseSvnClient;
+import org.jetbrains.idea.svn.api.Depth;
+import org.jetbrains.idea.svn.api.NodeKind;
import org.jetbrains.idea.svn.checkin.CmdCheckinClient;
+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.SvnBindException;
import org.jetbrains.idea.svn.commandLine.SvnCommandName;
-import org.tmatesoft.svn.core.*;
+import org.jetbrains.idea.svn.lock.Lock;
+import org.tmatesoft.svn.core.SVNException;
+import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.wc.SVNRevision;
import org.tmatesoft.svn.core.wc2.SvnTarget;
@@ -35,7 +40,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;
/**
@@ -46,8 +50,8 @@ public class CmdBrowseClient extends BaseSvnClient implements BrowseClient {
@Override
public void list(@NotNull SvnTarget target,
@Nullable SVNRevision revision,
- @Nullable SVNDepth depth,
- @Nullable ISVNDirEntryHandler handler) throws VcsException {
+ @Nullable Depth depth,
+ @Nullable DirectoryEntryConsumer handler) throws VcsException {
assertUrl(target);
List<String> parameters = new ArrayList<String>();
@@ -85,15 +89,15 @@ public class CmdBrowseClient extends BaseSvnClient implements BrowseClient {
return listener.getCommittedRevision();
}
- private static void parseOutput(@NotNull SVNURL url, @NotNull CommandExecutor command, @Nullable ISVNDirEntryHandler handler)
- throws VcsException, SVNException {
+ private static void parseOutput(@NotNull SVNURL url, @NotNull CommandExecutor command, @Nullable DirectoryEntryConsumer handler)
+ throws VcsException, SVNException {
try {
TargetLists lists = CommandUtil.parse(command.getOutput(), TargetLists.class);
if (handler != null && lists != null) {
for (TargetList list : lists.lists) {
for (Entry entry : list.entries) {
- handler.handleDirEntry(entry.toDirEntry(url));
+ handler.consume(entry.toDirectoryEntry(url));
}
}
}
@@ -122,8 +126,8 @@ public class CmdBrowseClient extends BaseSvnClient implements BrowseClient {
public static class Entry {
- @XmlAttribute(name = "kind")
- public String kind;
+ @XmlAttribute(name = "kind", required = true)
+ public NodeKind kind;
@XmlElement(name = "name")
public String name;
@@ -131,68 +135,15 @@ public class CmdBrowseClient extends BaseSvnClient implements BrowseClient {
@XmlElement(name = "size")
public long size;
- @XmlElement(name = "commit")
- public Commit commit;
+ public CommitInfo.Builder commit;
- @XmlElement(name = "lock")
- public Lock lock;
+ public Lock.Builder lock;
- public long revision() {
- return commit != null ? commit.revision : 0;
- }
-
- public String author() {
- return commit != null ? commit.author : "";
- }
-
- public Date date() {
- return commit != null ? commit.date : null;
- }
-
- public SVNDirEntry toDirEntry(@NotNull SVNURL url) throws SVNException {
+ @NotNull
+ public DirectoryEntry toDirectoryEntry(@NotNull SVNURL url) throws SVNException {
// TODO: repository is not used for now
- SVNDirEntry entry =
- new SVNDirEntry(url.appendPath(name, false), null, PathUtil.getFileName(name), SVNNodeKind.parseKind(kind), size, false, revision(),
- date(), author());
-
- entry.setRelativePath(name);
- entry.setLock(lock != null ? lock.toLock(entry.getRelativePath()) : null);
-
- return entry;
- }
- }
-
- public static class Commit {
-
- @XmlAttribute(name = "revision")
- public long revision;
-
- @XmlElement(name = "author")
- public String author;
-
- @XmlElement(name = "date")
- public Date date;
- }
-
- public static class Lock {
-
- @XmlElement(name = "token")
- public String token;
-
- @XmlElement(name = "owner")
- public String owner;
-
- @XmlElement(name = "comment")
- public String comment;
-
- @XmlElement(name = "created")
- public Date created;
-
- @XmlElement(name = "expires")
- public Date expires;
-
- public SVNLock toLock(@NotNull String path) {
- return new SVNLock(path, token, owner, comment, created, expires);
+ return new DirectoryEntry(url.appendPath(name, false), null, PathUtil.getFileName(name), kind,
+ commit != null ? commit.build() : null, name);
}
}
}
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/DirectoryEntry.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/DirectoryEntry.java
new file mode 100644
index 000000000000..e29e6e468bd1
--- /dev/null
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/DirectoryEntry.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.idea.svn.browse;
+
+import com.intellij.util.ObjectUtils;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.idea.svn.api.BaseNodeDescription;
+import org.jetbrains.idea.svn.api.NodeKind;
+import org.jetbrains.idea.svn.checkin.CommitInfo;
+import org.tmatesoft.svn.core.SVNDirEntry;
+import org.tmatesoft.svn.core.SVNURL;
+
+import java.util.Date;
+
+/**
+ * @author Konstantin Kolosovsky.
+ */
+public class DirectoryEntry extends BaseNodeDescription implements Comparable<DirectoryEntry> {
+
+ private final String myName;
+ @NotNull private final CommitInfo myCommitInfo;
+ private final String myPath;
+ private final SVNURL myUrl;
+ private final SVNURL myRepositoryRoot;
+
+ @NotNull
+ public static DirectoryEntry create(@NotNull SVNDirEntry entry) {
+ return new DirectoryEntry(entry.getURL(), entry.getRepositoryRoot(), entry.getName(), NodeKind.from(entry.getKind()),
+ new CommitInfo.Builder(entry.getRevision(), entry.getDate(), entry.getAuthor()).build(),
+ entry.getRelativePath());
+ }
+
+ public DirectoryEntry(SVNURL url,
+ SVNURL repositoryRoot,
+ String name,
+ @NotNull NodeKind kind,
+ @Nullable CommitInfo commitInfo,
+ String path) {
+ super(kind);
+ myUrl = url;
+ myRepositoryRoot = repositoryRoot;
+ myName = name;
+ myCommitInfo = ObjectUtils.notNull(commitInfo, CommitInfo.EMPTY);
+ myPath = path;
+ }
+
+ public SVNURL getUrl() {
+ return myUrl;
+ }
+
+ public SVNURL getRepositoryRoot() {
+ return myRepositoryRoot;
+ }
+
+ public String getName() {
+ return myName;
+ }
+
+ @NotNull
+ public NodeKind getKind() {
+ return myKind;
+ }
+
+ public Date getDate() {
+ return myCommitInfo.getDate();
+ }
+
+ public long getRevision() {
+ return myCommitInfo.getRevision();
+ }
+
+ public String getAuthor() {
+ return myCommitInfo.getAuthor();
+ }
+
+ public String getRelativePath() {
+ return myPath == null ? myName : myPath;
+ }
+
+ @Override
+ public int compareTo(@NotNull DirectoryEntry o) {
+ int result = getKind().compareTo(o.getKind());
+
+ return result != 0 ? result : myUrl.toString().compareTo(o.getUrl().toString());
+ }
+}
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/DirectoryEntryConsumer.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/DirectoryEntryConsumer.java
new file mode 100644
index 000000000000..f404413a6996
--- /dev/null
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/DirectoryEntryConsumer.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.idea.svn.browse;
+
+import com.intellij.util.ThrowableConsumer;
+import org.tmatesoft.svn.core.SVNException;
+
+/**
+ * @author Konstantin Kolosovsky.
+ */
+public interface DirectoryEntryConsumer extends ThrowableConsumer<DirectoryEntry, SVNException> {
+}
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/SvnKitBrowseClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/SvnKitBrowseClient.java
index 42ac680a6ab8..cdbb1ff1e67b 100644
--- a/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/SvnKitBrowseClient.java
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/SvnKitBrowseClient.java
@@ -20,6 +20,7 @@ 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.api.Depth;
import org.jetbrains.idea.svn.commandLine.SvnBindException;
import org.tmatesoft.svn.core.*;
import org.tmatesoft.svn.core.wc.SVNLogClient;
@@ -33,8 +34,8 @@ public class SvnKitBrowseClient extends BaseSvnClient implements BrowseClient {
@Override
public void list(@NotNull SvnTarget target,
@Nullable SVNRevision revision,
- @Nullable SVNDepth depth,
- @Nullable ISVNDirEntryHandler handler) throws VcsException {
+ @Nullable Depth depth,
+ @Nullable DirectoryEntryConsumer handler) throws VcsException {
assertUrl(target);
SVNLogClient client = myVcs.getSvnKitManager().createLogClient();
@@ -42,10 +43,10 @@ public class SvnKitBrowseClient extends BaseSvnClient implements BrowseClient {
try {
if (target.isFile()) {
- client.doList(target.getFile(), target.getPegRevision(), revision, true, depth, SVNDirEntry.DIRENT_ALL, wrappedHandler);
+ client.doList(target.getFile(), target.getPegRevision(), notNullize(revision), true, toDepth(depth), SVNDirEntry.DIRENT_ALL, wrappedHandler);
}
else {
- client.doList(target.getURL(), target.getPegRevision(), revision, true, depth, SVNDirEntry.DIRENT_ALL, wrappedHandler);
+ client.doList(target.getURL(), target.getPegRevision(), notNullize(revision), true, toDepth(depth), SVNDirEntry.DIRENT_ALL, wrappedHandler);
}
}
catch (SVNException e) {
@@ -69,26 +70,26 @@ public class SvnKitBrowseClient extends BaseSvnClient implements BrowseClient {
}
@Nullable
- private static ISVNDirEntryHandler wrapHandler(@Nullable ISVNDirEntryHandler handler) {
+ private static ISVNDirEntryHandler wrapHandler(@Nullable DirectoryEntryConsumer handler) {
return handler == null ? null : new SkipEmptyNameDirectoriesHandler(handler);
}
public static class SkipEmptyNameDirectoriesHandler implements ISVNDirEntryHandler {
- @NotNull private final ISVNDirEntryHandler handler;
+ @NotNull private final DirectoryEntryConsumer handler;
- public SkipEmptyNameDirectoriesHandler(@NotNull ISVNDirEntryHandler handler) {
+ public SkipEmptyNameDirectoriesHandler(@NotNull DirectoryEntryConsumer handler) {
this.handler = handler;
}
@Override
public void handleDirEntry(SVNDirEntry dirEntry) throws SVNException {
if (!isEmptyNameDirectory(dirEntry)) {
- handler.handleDirEntry(dirEntry);
+ handler.consume(DirectoryEntry.create(dirEntry));
}
}
- private static boolean isEmptyNameDirectory(SVNDirEntry dirEntry) {
+ private static boolean isEmptyNameDirectory(@NotNull SVNDirEntry dirEntry) {
return SVNNodeKind.DIR.equals(dirEntry.getKind()) && StringUtil.isEmpty(dirEntry.getName());
}
}