From d660da119f0cf86573a13fccdb32b28ee9ff87c6 Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Mon, 19 Feb 2018 19:11:38 +0300 Subject: [PATCH] lst: ensure that target changelist exists when updating base revision EA-115966 - assert: ChangeListWorker.getDataByIdVerify --- .../openapi/vcs/ex/DocumentTracker.kt | 2 +- .../openapi/vcs/ex/LineStatusTrackerBase.kt | 7 +++++++ .../vcs/ex/PartialLocalLineStatusTracker.kt | 20 ++++++++++++------- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/platform/diff-impl/src/com/intellij/openapi/vcs/ex/DocumentTracker.kt b/platform/diff-impl/src/com/intellij/openapi/vcs/ex/DocumentTracker.kt index fbeca8817b57..c207298c581b 100644 --- a/platform/diff-impl/src/com/intellij/openapi/vcs/ex/DocumentTracker.kt +++ b/platform/diff-impl/src/com/intellij/openapi/vcs/ex/DocumentTracker.kt @@ -184,7 +184,7 @@ class DocumentTracker : Disposable { } } - private fun updateFrozenContentIfNeeded() { + fun updateFrozenContentIfNeeded() { // ensure blocks are up to date updateFrozenContentIfNeeded(Side.LEFT) updateFrozenContentIfNeeded(Side.RIGHT) diff --git a/platform/diff-impl/src/com/intellij/openapi/vcs/ex/LineStatusTrackerBase.kt b/platform/diff-impl/src/com/intellij/openapi/vcs/ex/LineStatusTrackerBase.kt index f2e476333cec..73c6806238f2 100644 --- a/platform/diff-impl/src/com/intellij/openapi/vcs/ex/LineStatusTrackerBase.kt +++ b/platform/diff-impl/src/com/intellij/openapi/vcs/ex/LineStatusTrackerBase.kt @@ -94,6 +94,11 @@ abstract class LineStatusTrackerBase { @CalledInAwt fun setBaseRevision(vcsContent: CharSequence) { + setBaseRevision(vcsContent, null) + } + + @CalledInAwt + protected fun setBaseRevision(vcsContent: CharSequence, beforeUnfreeze: (() -> Unit)?) { application.assertIsDispatchThread() if (isReleased) return @@ -101,6 +106,8 @@ abstract class LineStatusTrackerBase { updateDocument(Side.LEFT) { vcsDocument.setText(vcsContent) } + + beforeUnfreeze?.invoke() } if (!isInitialized) { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/PartialLocalLineStatusTracker.kt b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/PartialLocalLineStatusTracker.kt index 66411bd141af..2da1ecef5e62 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/PartialLocalLineStatusTracker.kt +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/PartialLocalLineStatusTracker.kt @@ -144,15 +144,21 @@ class PartialLocalLineStatusTracker(project: Project, @CalledInAwt fun setBaseRevision(vcsContent: CharSequence, changelistId: String?) { - currentMarker = if (changelistId != null) ChangeListMarker(changelistId) else null - try { - setBaseRevision(vcsContent) - dropExistingUndoActions() - } - finally { - currentMarker = null + setBaseRevision(vcsContent) { + if (changelistId != null) { + changeListManager.executeUnderDataLock { + if (changeListManager.getChangeList(changelistId) != null) { + documentTracker.writeLock { + currentMarker = ChangeListMarker(changelistId) + documentTracker.updateFrozenContentIfNeeded() + currentMarker = null + } + } + } + } } + dropExistingUndoActions() if (isValid()) eventDispatcher.multicaster.onBecomingValid(this) }