mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
svn: Refactored NestedCopiesBuilder - code simplified, @NotNull
This commit is contained in:
@@ -15,53 +15,49 @@
|
||||
*/
|
||||
package org.jetbrains.idea.svn;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.idea.svn.status.Status;
|
||||
import org.jetbrains.idea.svn.status.StatusType;
|
||||
import org.tmatesoft.svn.core.SVNException;
|
||||
import org.tmatesoft.svn.core.SVNURL;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class NestedCopiesBuilder implements StatusReceiver {
|
||||
private final Set<NestedCopyInfo> mySet;
|
||||
private final Project myProject;
|
||||
private final SvnFileUrlMapping myMapping;
|
||||
|
||||
@NotNull private final Set<NestedCopyInfo> myCopies;
|
||||
@NotNull private final SvnFileUrlMapping myMapping;
|
||||
@NotNull private final SvnVcs myVcs;
|
||||
|
||||
public NestedCopiesBuilder(@NotNull final SvnVcs vcs, final SvnFileUrlMapping mapping) {
|
||||
public NestedCopiesBuilder(@NotNull SvnVcs vcs, @NotNull SvnFileUrlMapping mapping) {
|
||||
myVcs = vcs;
|
||||
myProject = vcs.getProject();
|
||||
myMapping = mapping;
|
||||
mySet = new HashSet<NestedCopyInfo>();
|
||||
myCopies = ContainerUtil.newHashSet();
|
||||
}
|
||||
|
||||
public void process(final FilePath path, final Status status) throws SVNException {
|
||||
public void process(@NotNull FilePath path, final Status status) {
|
||||
VirtualFile file = path.getVirtualFile();
|
||||
if (file != null && status.is(StatusType.STATUS_EXTERNAL)) {
|
||||
// We do not determine here url, repository url - because url, repository url in status will determine location in the
|
||||
// repository where folder is located and not where svn:externals property points. We want the later parameters - they'll
|
||||
// determined while creating RootUrlInfos later. Format will be also determined later.
|
||||
// TODO: Probably we could move that logic here.
|
||||
final NestedCopyInfo info = new NestedCopyInfo(file, null, WorkingCopyFormat.UNKNOWN, NestedCopyType.external, null);
|
||||
mySet.add(info);
|
||||
return;
|
||||
}
|
||||
if (file == null || status.getURL() == null) return;
|
||||
|
||||
if (!status.is(StatusType.STATUS_UNVERSIONED) && status.isSwitched()) {
|
||||
// this one called when there is switched directory under nested working copy
|
||||
// TODO: some other cases?
|
||||
final NestedCopyInfo
|
||||
info = new NestedCopyInfo(file, status.getURL(), myVcs.getWorkingCopyFormat(path.getIOFile()), NestedCopyType.switched,
|
||||
status.getRepositoryRootURL());
|
||||
mySet.add(info);
|
||||
if (file != null) {
|
||||
if (status.is(StatusType.STATUS_EXTERNAL)) {
|
||||
// We do not determine here url, repository url - because url, repository url in status will determine location in the
|
||||
// repository where folder is located and not where svn:externals property points. We want the later parameters - they'll
|
||||
// determined while creating RootUrlInfos later. Format will be also determined later.
|
||||
// TODO: Probably we could move that logic here.
|
||||
myCopies.add(new NestedCopyInfo(file, null, WorkingCopyFormat.UNKNOWN, NestedCopyType.external, null));
|
||||
}
|
||||
else if (status.getURL() != null && !status.is(StatusType.STATUS_UNVERSIONED) && status.isSwitched()) {
|
||||
// this one called when there is switched directory under nested working copy
|
||||
// TODO: some other cases?
|
||||
myCopies.add(new NestedCopyInfo(file, status.getURL(), myVcs.getWorkingCopyFormat(path.getIOFile()), NestedCopyType.switched,
|
||||
status.getRepositoryRootURL()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,17 +68,20 @@ public class NestedCopiesBuilder implements StatusReceiver {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCopyRoot(VirtualFile file, SVNURL url, WorkingCopyFormat format, SVNURL rootURL) {
|
||||
final NestedCopyInfo info = new NestedCopyInfo(file, url, format, NestedCopyType.inner, rootURL);
|
||||
mySet.add(info);
|
||||
public void processCopyRoot(@NotNull VirtualFile file,
|
||||
@Nullable SVNURL url,
|
||||
@NotNull WorkingCopyFormat format,
|
||||
@Nullable SVNURL rootURL) {
|
||||
myCopies.add(new NestedCopyInfo(file, url, format, NestedCopyType.inner, rootURL));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bewareRoot(VirtualFile vf, SVNURL url) {
|
||||
final File ioFile = new File(vf.getPath());
|
||||
public void bewareRoot(@NotNull VirtualFile vf, SVNURL url) {
|
||||
final File ioFile = VfsUtilCore.virtualToIoFile(vf);
|
||||
final RootUrlInfo info = myMapping.getWcRootForFilePath(ioFile);
|
||||
|
||||
if (info != null && FileUtil.filesEqual(ioFile, info.getIoFile()) && ! info.getAbsoluteUrlAsUrl().equals(url)) {
|
||||
SvnVcs.getInstance(myProject).invokeRefreshSvnRoots();
|
||||
myVcs.invokeRefreshSvnRoots();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +89,8 @@ public class NestedCopiesBuilder implements StatusReceiver {
|
||||
public void finish() {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Set<NestedCopyInfo> getCopies() {
|
||||
return mySet;
|
||||
return myCopies;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user