PY-82344 Remove update mock logic as the same logic is already presented in the platform

Remove outdated registry key for PyCharm promo testing

GitOrigin-RevId: fb22ce164ad88c54de6cd6938c6e91a9feea47ba
This commit is contained in:
Daniil Kalinin
2025-10-13 15:11:47 +00:00
committed by intellij-monorepo-bot
parent c25ab985dc
commit e0feb3b473
4 changed files with 4 additions and 50 deletions
@@ -28,7 +28,6 @@ jvm_library(
"//platform/core-ui",
"//python/ide/customization.shared",
"//platform/platform-impl/update-checker",
"//platform/util/jdom",
]
)
### auto-generated section `build intellij.pycharm.community.ide.impl.promotion` end
@@ -22,6 +22,5 @@
<orderEntry type="module" module-name="intellij.platform.core.ui" />
<orderEntry type="module" module-name="intellij.pycharm.community.customization.shared" />
<orderEntry type="module" module-name="intellij.platform.ide.updateChecker" />
<orderEntry type="module" module-name="intellij.platform.util.jdom" />
</component>
</module>
@@ -101,10 +101,6 @@
<postStartupActivity
implementation="com.intellij.pycharm.community.ide.impl.promotion.communityToUnified.PyCommunityToUnifiedShowPromoActivity"/>
<!--TODO delete later-->
<registryKey key="py.promo.use.test.update"
defaultValue="false"
description="Use py_promo_test.xml from IDE home to mock a platform update for PyCharm promo"/>
<!--TODO delete later-->
<registryKey key="py.promo.remind.later.interval.seconds"
defaultValue="259200"
description="PyCharm promo remind-later fallback delay in seconds"/>
@@ -3,13 +3,14 @@ package com.intellij.pycharm.community.ide.impl.promotion.communityToUnified
import com.intellij.ide.util.PropertiesComponent
import com.intellij.openapi.application.ApplicationInfo
import com.intellij.openapi.application.PathManager
import com.intellij.openapi.components.Service
import com.intellij.openapi.components.service
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.updateSettings.UpdateStrategyCustomization
import com.intellij.openapi.updateSettings.impl.*
import com.intellij.openapi.util.JDOMUtil
import com.intellij.openapi.updateSettings.impl.PlatformUpdates
import com.intellij.openapi.updateSettings.impl.UpdateCheckerFacade
import com.intellij.openapi.updateSettings.impl.UpdateSettings
import com.intellij.openapi.updateSettings.impl.UpdateStrategy
import com.intellij.openapi.util.registry.Registry
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@@ -18,8 +19,6 @@ import kotlinx.coroutines.sync.withLock
import kotlinx.coroutines.time.withTimeout
import kotlinx.coroutines.withContext
import org.jetbrains.annotations.ApiStatus
import java.nio.file.Files
import java.nio.file.Path
import java.time.Duration
/**
@@ -101,37 +100,6 @@ internal class PyCommunityToUnifiedPromoService(val serviceScope: CoroutineScope
}.getOrElse { null }
}
private fun readMockUpdateIfEnabled(): PlatformUpdates.Loaded? {
return try {
if (!Registry.`is`("py.promo.use.test.update", false)) return null
val path: Path = Path.of(PathManager.getHomePath(), "py_promo_test.xml")
if (!Files.isRegularFile(path)) {
LOG.info("Mock PY promo update enabled, but file not found: $path")
null
}
else {
val text = Files.readString(path)
val currentBuild = ApplicationInfo.getInstance().build
val productCode = currentBuild.productCode
val node = JDOMUtil.load(text)
.getChild("product")
?.getChild("channel")
?: throw IllegalArgumentException("//channel missing")
val channel = UpdateChannel(node, productCode)
val newBuild = channel.builds.firstOrNull()
?: throw IllegalArgumentException("//build missing")
val patches = newBuild.patches.firstOrNull()
?.let { UpdateChain(listOf(it.fromBuild, newBuild.number), it.size) }
return PlatformUpdates.Loaded(newBuild, channel, patches)
}
}
catch (t: Throwable) {
LOG.warn("Failed to read/parse mock PY promo update", t)
null
}
}
private suspend fun findAvailableUpdate(): PlatformUpdates.Loaded? {
return withContext(Dispatchers.IO) {
lock.withLock {
@@ -140,14 +108,6 @@ internal class PyCommunityToUnifiedPromoService(val serviceScope: CoroutineScope
return@withTimeout availableUpdate
}
// Try mocked update if registry flag is enabled
readMockUpdateIfEnabled()?.let { mockUpdate ->
if (mockUpdate.newBuild.number.productCode == "PY") {
availableUpdate = mockUpdate
return@withTimeout mockUpdate
}
}
val updateCheckerFacade = service<UpdateCheckerFacade>()
val product = updateCheckerFacade.loadProductData(null)
if (product == null) {