--- /dev/null
+/*
+ * Copyright 2000-2015 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 com.intellij.openapi.updateSettings;
+
+import com.intellij.openapi.components.ServiceManager;
+
+/**
+ * Override this service in your IDE to customize update behavior. It isn't supposed to be overriden in plugins.
+ */
+public class UpdateStrategyCustomization {
+ public static UpdateStrategyCustomization getInstance() {
+ return ServiceManager.getService(UpdateStrategyCustomization.class);
+ }
+
+ public boolean forceEapUpdateChannelForEapBuilds() {
+ return true;
+ }
+
+ /**
+ * Whether the updater will allow patch updates to cross major version boundaries.
+ */
+ public boolean allowMajorVersionUpdate() {
+ return false;
+ }
+}
import com.intellij.openapi.application.ApplicationInfo;
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
import com.intellij.openapi.components.*;
+import com.intellij.openapi.updateSettings.UpdateStrategyCustomization;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.SmartList;
import com.intellij.util.containers.ContainerUtil;
}
private void updateDefaultChannel() {
- if (ApplicationInfoImpl.getShadowInstance().isEAP()) {
+ if (UpdateStrategyCustomization.getInstance().forceEapUpdateChannelForEapBuilds() && ApplicationInfoImpl.getShadowInstance().isEAP()) {
myState.UPDATE_CHANNEL_TYPE = ChannelStatus.EAP_CODE;
}
}
public boolean canUseSecureConnection() {
return myState.SECURE_CONNECTION && NetUtils.isSniEnabled();
}
-}
\ No newline at end of file
+}
*/
package com.intellij.openapi.updateSettings.impl;
+import com.intellij.openapi.updateSettings.UpdateStrategyCustomization;
import com.intellij.openapi.util.BuildNumber;
import org.jetbrains.annotations.NotNull;
List<UpdateChannel> channels = product.getChannels();
List<UpdateChannel> result = new ArrayList<UpdateChannel>();
for (UpdateChannel channel : channels) {
- if ((channel.getMajorVersion() == myMajorVersion && channel.getStatus().compareTo(myChannelStatus) >= 0) ||
- (channel.getMajorVersion() > myMajorVersion && channel.getStatus() == ChannelStatus.EAP && myChannelStatus == ChannelStatus.EAP)) {
- if (channel.getMajorVersion() == myMajorVersion && channel.getStatus().compareTo(myChannelStatus) == 0) {
- result.add(0, channel); // prefer channel that has same status as our selected channel status
- } else {
- result.add(channel);
+
+ // If the update is to a new version and on a stabler channel, choose it.
+ if ((channel.getMajorVersion() >= myMajorVersion && channel.getStatus().compareTo(myChannelStatus) >= 0)) {
+ if (UpdateStrategyCustomization.getInstance().allowMajorVersionUpdate()
+ || channel.getMajorVersion() == myMajorVersion
+ || channel.getStatus() == ChannelStatus.EAP && myChannelStatus == ChannelStatus.EAP) {
+ // Prefer channel that has same status as our selected channel status
+ if (channel.getMajorVersion() == myMajorVersion && channel.getStatus().compareTo(myChannelStatus) == 0) {
+ result.add(0, channel);
+ }
+ else {
+ result.add(channel);
+ }
}
}
}
serviceImplementation="com.intellij.openapi.editor.impl.EditorActionManagerImpl"/>
<applicationService serviceInterface="com.intellij.openapi.updateSettings.impl.UpdateSettings"
serviceImplementation="com.intellij.openapi.updateSettings.impl.UpdateSettings"/>
+ <applicationService serviceImplementation="com.intellij.openapi.updateSettings.UpdateStrategyCustomization"/>
<applicationService serviceInterface="com.intellij.ide.plugins.InstalledPluginsState"
serviceImplementation="com.intellij.ide.plugins.InstalledPluginsState"/>
<applicationService serviceInterface="com.intellij.featureStatistics.FeatureUsageTracker"