svn: Refactoring - BranchesPreloader logic moved to NewRootBunch, removed BranchesPreloader

This commit is contained in:
Konstantin Kolosovsky
2014-08-09 21:34:21 +04:00
parent 5162822198
commit 60c4e91ff0
3 changed files with 18 additions and 59 deletions
@@ -1,54 +0,0 @@
/*
* 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.branchConfig;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.idea.svn.SvnVcs;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
/**
* @author Konstantin Kolosovsky.
*/
public class BranchesPreloader {
private final Project myProject;
private final VirtualFile myRoot;
private final NewRootBunch myBunch;
public BranchesPreloader(Project project, @NotNull final NewRootBunch bunch, VirtualFile root) {
myBunch = bunch;
myProject = project;
myRoot = root;
}
public void loadImpl(final SvnBranchConfigurationNew prev, final SvnBranchConfigurationNew next) {
final Set<String> oldUrls = (prev == null) ? Collections.<String>emptySet() : new HashSet<String>(prev.getBranchUrls());
final SvnVcs vcs = SvnVcs.getInstance(myProject);
if (! vcs.isVcsBackgroundOperationsAllowed(myRoot)) return;
for (String newBranchUrl : next.getBranchUrls()) {
// check if cancel had been put
if (! vcs.isVcsBackgroundOperationsAllowed(myRoot)) return;
if (!oldUrls.contains(newBranchUrl)) {
new BranchesLoader(myProject, myBunch, newBranchUrl, InfoReliability.defaultValues, myRoot, true).run();
}
}
}
}
@@ -24,12 +24,11 @@ import com.intellij.openapi.vcs.CalledInBackground;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.svn.SvnVcs;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
// synch is here
public class NewRootBunch {
@@ -66,7 +65,7 @@ public class NewRootBunch {
myBranchesLoader.run(new Runnable() {
@Override
public void run() {
new BranchesPreloader(myProject, NewRootBunch.this, root).loadImpl(previous, config.getValue());
reloadBranches(root, previous, config.getValue());
}
});
}
@@ -106,6 +105,20 @@ public class NewRootBunch {
.executeOnPooledThread(new BranchesLoader(myProject, this, branchParentUrl, InfoReliability.setByUser, root, true));
}
public void reloadBranches(@NotNull VirtualFile root, @Nullable SvnBranchConfigurationNew prev, @NotNull SvnBranchConfigurationNew next) {
final Set<String> oldUrls = (prev == null) ? Collections.<String>emptySet() : new HashSet<String>(prev.getBranchUrls());
final SvnVcs vcs = SvnVcs.getInstance(myProject);
if (!vcs.isVcsBackgroundOperationsAllowed(root)) return;
for (String newBranchUrl : next.getBranchUrls()) {
// check if cancel had been put
if (!vcs.isVcsBackgroundOperationsAllowed(root)) return;
if (!oldUrls.contains(newBranchUrl)) {
new BranchesLoader(myProject, this, newBranchUrl, InfoReliability.defaultValues, root, true).run();
}
}
}
@Nullable
@CalledInBackground
public SVNURL getWorkingBranchWithReload(final SVNURL svnurl, final VirtualFile root) {
@@ -202,7 +202,7 @@ public class SvnBranchConfigurationManager implements PersistentStateComponent<S
public void run() {
try {
for (Pair<VirtualFile, SvnBranchConfigurationNew> pair : branchPoints) {
new BranchesPreloader(myProject, myBunch, pair.getFirst()).loadImpl(null, pair.getSecond());
myBunch.reloadBranches(pair.getFirst(), null, pair.getSecond());
}
}
catch (ProcessCanceledException e) {