From 60c4e91ff0e7e8b22fd101a9270d873eb71dee71 Mon Sep 17 00:00:00 2001 From: Konstantin Kolosovsky Date: Sat, 9 Aug 2014 21:34:21 +0400 Subject: [PATCH] svn: Refactoring - BranchesPreloader logic moved to NewRootBunch, removed BranchesPreloader --- .../svn/branchConfig/BranchesPreloader.java | 54 ------------------- .../idea/svn/branchConfig/NewRootBunch.java | 21 ++++++-- .../SvnBranchConfigurationManager.java | 2 +- 3 files changed, 18 insertions(+), 59 deletions(-) delete mode 100644 plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/BranchesPreloader.java diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/BranchesPreloader.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/BranchesPreloader.java deleted file mode 100644 index 5d8a4295a3e2..000000000000 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/BranchesPreloader.java +++ /dev/null @@ -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 oldUrls = (prev == null) ? Collections.emptySet() : new HashSet(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(); - } - } - } -} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/NewRootBunch.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/NewRootBunch.java index 63166f1183cb..6e4bfa2c3c8a 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/NewRootBunch.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/NewRootBunch.java @@ -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 oldUrls = (prev == null) ? Collections.emptySet() : new HashSet(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) { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/SvnBranchConfigurationManager.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/SvnBranchConfigurationManager.java index eaabb920feb7..772e5edd2755 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/SvnBranchConfigurationManager.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/SvnBranchConfigurationManager.java @@ -202,7 +202,7 @@ public class SvnBranchConfigurationManager implements PersistentStateComponent pair : branchPoints) { - new BranchesPreloader(myProject, myBunch, pair.getFirst()).loadImpl(null, pair.getSecond()); + myBunch.reloadBranches(pair.getFirst(), null, pair.getSecond()); } } catch (ProcessCanceledException e) {