From de8307d16652cfb569132d6e08f736ec324d7c1d Mon Sep 17 00:00:00 2001 From: irengrig Date: Tue, 19 Jan 2010 15:31:26 +0300 Subject: [PATCH] IDEA-27188 (too many svn requests) --- .../src/messages/VcsBundle.properties | 5 +- .../com/intellij/openapi/vcs/VcsConfiguration.java | 4 +- .../vcs/changes/LazyRefreshingSelfQueue.java | 8 +-- .../vcs/changes/RemoteRevisionsNumbersCache.java | 21 +++--- .../vcs/changes/RemoteRevisionsStateCache.java | 7 +- .../vcs/changes/committed/CacheSettingsDialog.java | 9 ++- .../vcs/changes/committed/CacheSettingsPanel.java | 19 ++++- .../VcsBackgroundOperationsConfigurationPanel.form | 81 ++++++++++++++++++++-- .../VcsBackgroundOperationsConfigurationPanel.java | 36 +++++++++- .../vcs/configurable/VcsManagerConfigurable.java | 9 ++- 10 files changed, 166 insertions(+), 33 deletions(-) diff --git a/platform/platform-resources-en/src/messages/VcsBundle.properties b/platform/platform-resources-en/src/messages/VcsBundle.properties index f097c83195..688f95e45b 100644 --- a/platform/platform-resources-en/src/messages/VcsBundle.properties +++ b/platform/platform-resources-en/src/messages/VcsBundle.properties @@ -532,6 +532,9 @@ annotation.switch.to.merged.text=Show merge sources all.vcs.init.message.text=Initializing VCS... switch.to.changelist=Switch &to changelist (''{0}'') move.to.changelist=&Move changes to active changelist (''{0}'') -vcs.config.track.changed.on.server=Check "changed on server" conflicts in background +vcs.config.track.changed.on.server=Check every vcs.quicklist.pupup.title=VCS Quick List vcs.quicklist.pupup.section.local.history=Local History +options.background.processes.title=Background processes +options.background.processes.enable=Enable background processes +options.check.changed.on.server.title="Changed on server" conflicts diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/VcsConfiguration.java b/platform/vcs-api/src/com/intellij/openapi/vcs/VcsConfiguration.java index f0dac0c93a..b541005305 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/VcsConfiguration.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/VcsConfiguration.java @@ -22,10 +22,10 @@ import com.intellij.openapi.components.Storage; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.PerformInBackgroundOption; import com.intellij.openapi.project.Project; +import com.intellij.openapi.startup.StartupManager; import com.intellij.openapi.util.DefaultJDOMExternalizer; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.WriteExternalException; -import com.intellij.openapi.startup.StartupManager; import org.jdom.Element; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -63,6 +63,8 @@ public final class VcsConfiguration implements PersistentStateComponent public boolean PERFORM_ROLLBACK_IN_BACKGROUND = false; public volatile boolean CHECK_LOCALLY_CHANGED_CONFLICTS_IN_BACKGROUND = true; public VcsShowConfirmationOption.Value MOVE_TO_FAILED_COMMIT_CHANGELIST = VcsShowConfirmationOption.Value.SHOW_CONFIRMATION; + public boolean ENABLE_BACKGROUND_PROCESSES = true; + public int CHANGED_ON_SERVER_INTERVAL = 5; public enum StandardOption { ADD(VcsBundle.message("vcs.command.name.add")), diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/LazyRefreshingSelfQueue.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/LazyRefreshingSelfQueue.java index 9b15be6698..7a8736af17 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/LazyRefreshingSelfQueue.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/LazyRefreshingSelfQueue.java @@ -17,9 +17,9 @@ package com.intellij.openapi.vcs.changes; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProgressIndicator; -import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.progress.SomeQueue; import com.intellij.openapi.util.Computable; +import com.intellij.openapi.util.Getter; import com.intellij.openapi.util.Pair; import com.intellij.util.Consumer; import org.jetbrains.annotations.NotNull; @@ -36,7 +36,7 @@ import java.util.*; public class LazyRefreshingSelfQueue { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.changes.LazyRefreshingSelfQueue"); - private final long myUpdateInterval; + private final Getter myUpdateInterval; // head is old. tail is new private final LinkedList> myQueue; private final Set myInProgress; @@ -44,7 +44,7 @@ public class LazyRefreshingSelfQueue { private final Consumer myUpdater; private final Object myLock; - public LazyRefreshingSelfQueue(final long updateInterval, final Computable shouldUpdateOldChecker, final Consumer updater) { + public LazyRefreshingSelfQueue(final Getter updateInterval, final Computable shouldUpdateOldChecker, final Consumer updater) { myUpdateInterval = updateInterval; myShouldUpdateOldChecker = shouldUpdateOldChecker; myUpdater = updater; @@ -83,7 +83,7 @@ public class LazyRefreshingSelfQueue { public void updateStep(@NotNull final ProgressIndicator pi) { final List dirty = new LinkedList(); - final long startTime = System.currentTimeMillis() - myUpdateInterval; + final long startTime = System.currentTimeMillis() - myUpdateInterval.get(); boolean onlyAbsolute = true; // check if we have some old items at all - if not, we would not check if repository latest revision had changed and will save time synchronized (myLock) { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/RemoteRevisionsNumbersCache.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/RemoteRevisionsNumbersCache.java index d46e74cfc6..3bffcee4b2 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/RemoteRevisionsNumbersCache.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/RemoteRevisionsNumbersCache.java @@ -21,11 +21,9 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Computable; +import com.intellij.openapi.util.Getter; import com.intellij.openapi.util.Pair; -import com.intellij.openapi.vcs.AbstractVcs; -import com.intellij.openapi.vcs.FilePathImpl; -import com.intellij.openapi.vcs.ProjectLevelVcsManager; -import com.intellij.openapi.vcs.VcsRoot; +import com.intellij.openapi.vcs.*; import com.intellij.openapi.vcs.diff.DiffProvider; import com.intellij.openapi.vcs.diff.ItemLatestState; import com.intellij.openapi.vcs.history.VcsRevisionNumber; @@ -44,8 +42,9 @@ import java.util.*; public class RemoteRevisionsNumbersCache implements ChangesOnServerTracker { public static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.changes.RemoteRevisionsNumbersCache"); - // every 5 minutes.. (time unit to check for server commits) - private static final long ourRottenPeriod = 300 * 1000; + // every hour (time unit to check for server commits) + // default, actual in settings + private static final long ourRottenPeriod = 3600 * 1000; private final Map> myData; private final Map> myRefreshingQueues; private final Map myLatestRevisionsMap; @@ -75,6 +74,7 @@ public class RemoteRevisionsNumbersCache implements ChangesOnServerTracker { return -1; } }; + private final VcsConfiguration myVcsConfiguration; RemoteRevisionsNumbersCache(final Project project) { myLock = new Object(); @@ -83,6 +83,7 @@ public class RemoteRevisionsNumbersCache implements ChangesOnServerTracker { myLatestRevisionsMap = new HashMap(); myLfs = LocalFileSystem.getInstance(); myVcsManager = ProjectLevelVcsManager.getInstance(project); + myVcsConfiguration = VcsConfiguration.getInstance(project); } public boolean updateStep(final AtomicSectionsAware atomicSectionsAware) { @@ -200,7 +201,11 @@ public class RemoteRevisionsNumbersCache implements ChangesOnServerTracker { LazyRefreshingSelfQueue queue = myRefreshingQueues.get(vcsRoot); if (queue != null) return queue; - queue = new LazyRefreshingSelfQueue(ourRottenPeriod, new MyShouldUpdateChecker(vcsRoot), new MyUpdater(vcsRoot)); + queue = new LazyRefreshingSelfQueue(new Getter() { + public Long get() { + return myVcsConfiguration.CHANGED_ON_SERVER_INTERVAL > 0 ? myVcsConfiguration.CHANGED_ON_SERVER_INTERVAL * 60000 : ourRottenPeriod; + } + }, new MyShouldUpdateChecker(vcsRoot), new MyUpdater(vcsRoot)); myRefreshingQueues.put(vcsRoot, queue); return queue; } @@ -215,7 +220,7 @@ public class RemoteRevisionsNumbersCache implements ChangesOnServerTracker { public void consume(String s) { LOG.debug("update for: " + s); - //todo check canceled + //todo check canceled - check VCS's ready for asynchronous queries final VirtualFile vf = myLfs.refreshAndFindFileByIoFile(new File(s)); final ItemLatestState state; final DiffProvider diffProvider = myVcsRoot.vcs.getDiffProvider(); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/RemoteRevisionsStateCache.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/RemoteRevisionsStateCache.java index 8624beb026..16f8e0affa 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/RemoteRevisionsStateCache.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/RemoteRevisionsStateCache.java @@ -27,7 +27,7 @@ import java.io.File; import java.util.*; public class RemoteRevisionsStateCache implements ChangesOnServerTracker { - private final static long DISCRETE = 600000; + private final static long DISCRETE = 3600000; // true -> changed private final Map> myChanged; @@ -35,6 +35,7 @@ public class RemoteRevisionsStateCache implements ChangesOnServerTracker { private final Map myTs; private final Object myLock; private ProjectLevelVcsManager myVcsManager; + private final VcsConfiguration myVcsConfiguration; RemoteRevisionsStateCache(final Project project) { myVcsManager = ProjectLevelVcsManager.getInstance(project); @@ -42,6 +43,7 @@ public class RemoteRevisionsStateCache implements ChangesOnServerTracker { myQueries = new MultiMap(); myTs = new HashMap(); myLock = new Object(); + myVcsConfiguration = VcsConfiguration.getInstance(project); } public void invalidate(final Collection paths) { @@ -96,7 +98,8 @@ public class RemoteRevisionsStateCache implements ChangesOnServerTracker { public boolean updateStep(final AtomicSectionsAware atomicSectionsAware) { final MultiMap dirty = new MultiMap(); - final long oldPoint = System.currentTimeMillis() - DISCRETE; + final long oldPoint = System.currentTimeMillis() - (myVcsConfiguration.CHANGED_ON_SERVER_INTERVAL > 0 ? + myVcsConfiguration.CHANGED_ON_SERVER_INTERVAL * 60000 : DISCRETE); synchronized (myLock) { for (VcsRoot root : myQueries.keySet()) { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CacheSettingsDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CacheSettingsDialog.java index 2ea571482a..72850b4e28 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CacheSettingsDialog.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CacheSettingsDialog.java @@ -19,6 +19,7 @@ import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.vcs.VcsBundle; +import com.intellij.openapi.vcs.VcsConfiguration; import javax.swing.*; @@ -27,11 +28,14 @@ import javax.swing.*; */ public class CacheSettingsDialog extends DialogWrapper { private final CacheSettingsPanel myPanel; + private final Project myProject; public CacheSettingsDialog(Project project) { super(project, false); + myProject = project; setTitle(VcsBundle.message("cache.settings.dialog.title")); - myPanel = new CacheSettingsPanel(project); + myPanel = new CacheSettingsPanel(); + myPanel.initPanel(project); myPanel.reset(); init(); } @@ -41,6 +45,9 @@ public class CacheSettingsDialog extends DialogWrapper { protected void doOKAction() { try { + if (myPanel.isCachingEnabled()) { + VcsConfiguration.getInstance(myProject).ENABLE_BACKGROUND_PROCESSES = true; + } myPanel.apply(); } catch (ConfigurationException e) { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CacheSettingsPanel.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CacheSettingsPanel.java index 6591656112..9e6e0fa8ed 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CacheSettingsPanel.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CacheSettingsPanel.java @@ -35,14 +35,17 @@ public class CacheSettingsPanel implements Configurable { private JSpinner myDaysSpinner; private JLabel myCountLabel; private JLabel myDaysLabel; - private final CommittedChangesCache myCache; + private CommittedChangesCache myCache; - public CacheSettingsPanel(Project project) { + public CacheSettingsPanel() { myRefreshCheckbox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateControls(); } }); + } + + public void initPanel(final Project project) { myCache = CommittedChangesCache.getInstance(project); } @@ -112,4 +115,16 @@ public class CacheSettingsPanel implements Configurable { public void disposeUIResources() { } + + public void setEnableCaching(final boolean value) { + myRefreshCheckbox.setSelected(value); + } + + public void setEnabled(final boolean value) { + myRefreshCheckbox.setEnabled(value); + } + + public boolean isCachingEnabled() { + return myRefreshCheckbox.isSelected(); + } } \ No newline at end of file diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsBackgroundOperationsConfigurationPanel.form b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsBackgroundOperationsConfigurationPanel.form index c00dd1be23..224bf43af9 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsBackgroundOperationsConfigurationPanel.form +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsBackgroundOperationsConfigurationPanel.form @@ -16,7 +16,7 @@ - + @@ -84,14 +84,81 @@ - + + - + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsBackgroundOperationsConfigurationPanel.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsBackgroundOperationsConfigurationPanel.java index 934146553f..4051c509f8 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsBackgroundOperationsConfigurationPanel.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsBackgroundOperationsConfigurationPanel.java @@ -21,9 +21,12 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.vcs.VcsConfiguration; import com.intellij.openapi.vcs.VcsShowOptionsSettingImpl; import com.intellij.openapi.vcs.changes.RemoteRevisionsCache; +import com.intellij.openapi.vcs.changes.committed.CacheSettingsPanel; import org.jetbrains.annotations.Nls; import javax.swing.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.util.LinkedHashMap; import java.util.Map; @@ -40,11 +43,28 @@ public class VcsBackgroundOperationsConfigurationPanel implements Configurable { private JCheckBox myCbCheckoutInBackground; private JCheckBox myPerformRevertInBackgroundCheckBox; private JCheckBox myTrackChangedOnServer; + private JCheckBox myEnableBackgroundProcesses; + private JComponent myCachePanel; + private JSpinner myChangedOnServerInterval; + private JPanel myCachedCommittedChanges; + private CacheSettingsPanel myCacheSettingsPanel; public VcsBackgroundOperationsConfigurationPanel(final Project project) { - myProject = project; + myEnableBackgroundProcesses.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + final boolean backgroundEnabled = myEnableBackgroundProcesses.isSelected(); + if (! backgroundEnabled) { + myCacheSettingsPanel.setEnableCaching(false); + myTrackChangedOnServer.setSelected(false); + } + myTrackChangedOnServer.setEnabled(backgroundEnabled); + myCacheSettingsPanel.setEnabled(backgroundEnabled); + } + }); + myCacheSettingsPanel.initPanel(project); + myChangedOnServerInterval.setModel(new SpinnerNumberModel(5, 5, 48 * 10 * 60, 5)); } public void apply() throws ConfigurationException { @@ -61,11 +81,14 @@ public class VcsBackgroundOperationsConfigurationPanel implements Configurable { RemoteRevisionsCache.getInstance(myProject).startRefreshInBackground(); } settings.CHECK_LOCALLY_CHANGED_CONFLICTS_IN_BACKGROUND = myTrackChangedOnServer.isSelected(); + settings.CHANGED_ON_SERVER_INTERVAL = ((Number) myChangedOnServerInterval.getValue()).intValue(); + settings.ENABLE_BACKGROUND_PROCESSES = myEnableBackgroundProcesses.isSelected(); for (VcsShowOptionsSettingImpl setting : myPromptOptions.keySet()) { setting.setValue(myPromptOptions.get(setting).isSelected()); } + myCacheSettingsPanel.apply(); } public boolean isModified() { @@ -95,7 +118,9 @@ public class VcsBackgroundOperationsConfigurationPanel implements Configurable { if (settings.CHECK_LOCALLY_CHANGED_CONFLICTS_IN_BACKGROUND != myTrackChangedOnServer.isSelected()) { return true; } - + if (settings.ENABLE_BACKGROUND_PROCESSES != myEnableBackgroundProcesses.isSelected()) return true; + if (myCacheSettingsPanel.isModified()) return true; + if (settings.CHANGED_ON_SERVER_INTERVAL != ((Number) myChangedOnServerInterval.getValue()).intValue()) return true; return false; } @@ -111,6 +136,9 @@ public class VcsBackgroundOperationsConfigurationPanel implements Configurable { for (VcsShowOptionsSettingImpl setting : myPromptOptions.keySet()) { myPromptOptions.get(setting).setSelected(setting.getValue()); } + myEnableBackgroundProcesses.setSelected(settings.ENABLE_BACKGROUND_PROCESSES); + myChangedOnServerInterval.setValue(settings.CHANGED_ON_SERVER_INTERVAL); + myCacheSettingsPanel.reset(); } public JComponent getPanel() { @@ -137,4 +165,8 @@ public class VcsBackgroundOperationsConfigurationPanel implements Configurable { public void disposeUIResources() { } + private void createUIComponents() { + myCacheSettingsPanel = new CacheSettingsPanel(); + myCachePanel = myCacheSettingsPanel.createComponent(); + } } \ No newline at end of file diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsManagerConfigurable.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsManagerConfigurable.java index ef95f8248a..f4a7301636 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsManagerConfigurable.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsManagerConfigurable.java @@ -23,10 +23,9 @@ import com.intellij.openapi.util.IconLoader; import com.intellij.openapi.vcs.AbstractVcs; import com.intellij.openapi.vcs.ProjectLevelVcsManager; import com.intellij.openapi.vcs.VcsBundle; -import com.intellij.openapi.vcs.changes.committed.CacheSettingsPanel; -import com.intellij.openapi.vcs.changes.ui.IgnoredSettingsPanel; -import com.intellij.openapi.vcs.changes.conflicts.ChangelistConflictConfigurable; import com.intellij.openapi.vcs.changes.ChangeListManagerImpl; +import com.intellij.openapi.vcs.changes.conflicts.ChangelistConflictConfigurable; +import com.intellij.openapi.vcs.changes.ui.IgnoredSettingsPanel; import org.jetbrains.annotations.Nls; import javax.swing.*; @@ -120,9 +119,9 @@ public class VcsManagerConfigurable extends SearchableConfigurable.Parent.Abstra result.add(myGeneralPanel); result.add(new VcsBackgroundOperationsConfigurationPanel(myProject)); result.add(new IgnoredSettingsPanel(myProject)); - if (!myProject.isDefault()) { + /*if (!myProject.isDefault()) { result.add(new CacheSettingsPanel(myProject)); - } + }*/ result.add(new IssueNavigationConfigurationPanel(myProject)); result.add(new ChangelistConflictConfigurable(ChangeListManagerImpl.getInstanceImpl(myProject))); AbstractVcs[] vcses = ProjectLevelVcsManager.getInstance(myProject).getAllVcss(); -- 2.11.4.GIT