diff --git a/platform/platform-resources-en/src/messages/VcsBundle.properties b/platform/platform-resources-en/src/messages/VcsBundle.properties index fb0408106fe5..3f931bc88d4c 100644 --- a/platform/platform-resources-en/src/messages/VcsBundle.properties +++ b/platform/platform-resources-en/src/messages/VcsBundle.properties @@ -135,7 +135,8 @@ action.name.show.difference=Show Difference dialog.title.diff.for.range=Diff for Range diff.content.title.up.to.date=Base revision diff.content.title.current.range=Current -settings.filter.update.project.info.by.scope = Filter Update Project information by scope +settings.filter.update.project.info.by.scope=Filter Update Project information by scope +settings.partial.changelists.enable.checkbox=Track changed blocks in text files separately #file view action.name.show.files.as.tree=Show as Tree diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index a4864033ef0f..05368f6055be 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -471,9 +471,8 @@ vcs.root.detector.folder.depth.description=How deep should the IDE scan the file vcs.push.all.with.commits=false vcs.push.all.with.commits.description=Preselect all repositories with commits to be pushed by default. -vcs.enable.partial.changelists=false +vcs.enable.partial.changelists=true vcs.enable.partial.changelists.description=Allow to have one file in multiple changelists (tracking blocks of modified lines) -vcs.enable.partial.changelists.restartRequired=true vcs.enable.partial.changelists.persist.file.contents=false vcs.enable.partial.changelists.persist.file.contents.description=Persist file contents on disk to restore partial changes for files modified while IDE is closed 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 9f4e48781715..26803cd82142 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/VcsConfiguration.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/VcsConfiguration.java @@ -70,6 +70,7 @@ public final class VcsConfiguration implements PersistentStateComponent IGNORED_UNREGISTERED_ROOTS = ContainerUtil.newArrayList(); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictConfigurable.form b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictConfigurable.form index 47d2562c1353..ea1a5c03f81c 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictConfigurable.form +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictConfigurable.form @@ -1,16 +1,16 @@
- + - + - + - + @@ -19,7 +19,7 @@ - + @@ -91,9 +91,17 @@ - + + + + + + + + + diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictConfigurable.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictConfigurable.java index a6b80dc137a3..0bd4c85747fd 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictConfigurable.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictConfigurable.java @@ -15,6 +15,7 @@ */ package com.intellij.openapi.vcs.changes.conflicts; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.options.Configurable; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.options.SearchableConfigurable; @@ -22,7 +23,9 @@ import com.intellij.openapi.options.binding.BindControl; import com.intellij.openapi.options.binding.BindableConfigurable; import com.intellij.openapi.options.binding.ControlBinder; import com.intellij.openapi.vcs.VcsBundle; +import com.intellij.openapi.vcs.VcsConfiguration; import com.intellij.openapi.vcs.changes.ChangeListManagerImpl; +import com.intellij.openapi.vcs.impl.LineStatusTrackerSettingListener; import com.intellij.ui.components.JBList; import com.intellij.util.ArrayUtil; import com.intellij.util.ui.UIUtil; @@ -43,7 +46,7 @@ public class ChangelistConflictConfigurable extends BindableConfigurable impleme private JPanel myOptionsPanel; @BindControl("TRACKING_ENABLED") - private JCheckBox myEnableCheckBox; + private JCheckBox myEnableConflictTrackingCheckBox; @BindControl("SHOW_DIALOG") private JCheckBox myShowDialogCheckBox; @@ -56,16 +59,19 @@ public class ChangelistConflictConfigurable extends BindableConfigurable impleme private JBList myIgnoredFiles; private JButton myClearButton; + private JCheckBox myEnablePartialChangelists; private boolean myIgnoredFilesCleared; private final ChangelistConflictTracker myConflictTracker; + private final VcsConfiguration myVcsConfiguration; public ChangelistConflictConfigurable(ChangeListManagerImpl manager) { super(new ControlBinder(manager.getConflictTracker().getOptions())); - - myEnableCheckBox.addActionListener(new ActionListener() { + myVcsConfiguration = VcsConfiguration.getInstance(manager.getProject()); + + myEnableConflictTrackingCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - UIUtil.setEnabled(myOptionsPanel, myEnableCheckBox.isSelected(), true); + UIUtil.setEnabled(myOptionsPanel, myEnableConflictTrackingCheckBox.isSelected(), true); } }); myConflictTracker = manager.getConflictTracker(); @@ -89,10 +95,12 @@ public class ChangelistConflictConfigurable extends BindableConfigurable impleme @Override public void reset() { super.reset(); + myEnablePartialChangelists.setSelected(myVcsConfiguration.ENABLE_PARTIAL_CHANGELISTS); + Collection conflicts = myConflictTracker.getIgnoredConflicts(); myIgnoredFiles.setListData(ArrayUtil.toStringArray(conflicts)); myClearButton.setEnabled(!conflicts.isEmpty()); - UIUtil.setEnabled(myOptionsPanel, myEnableCheckBox.isSelected(), true); + UIUtil.setEnabled(myOptionsPanel, myEnableConflictTrackingCheckBox.isSelected(), true); } @Override @@ -103,17 +111,23 @@ public class ChangelistConflictConfigurable extends BindableConfigurable impleme conflict.ignored = false; } } + if (myEnablePartialChangelists.isSelected() != myVcsConfiguration.ENABLE_PARTIAL_CHANGELISTS) { + myVcsConfiguration.ENABLE_PARTIAL_CHANGELISTS = myEnablePartialChangelists.isSelected(); + ApplicationManager.getApplication().getMessageBus().syncPublisher(LineStatusTrackerSettingListener.TOPIC).settingsUpdated(); + } myConflictTracker.optionsChanged(); } @Override public boolean isModified() { - return super.isModified() || myIgnoredFiles.getModel().getSize() != myConflictTracker.getIgnoredConflicts().size(); + return super.isModified() || + myIgnoredFiles.getModel().getSize() != myConflictTracker.getIgnoredConflicts().size() || + myEnablePartialChangelists.isSelected() != myVcsConfiguration.ENABLE_PARTIAL_CHANGELISTS; } @Nls public String getDisplayName() { - return "Changelist Conflicts"; + return "Changelists"; } @Override diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/LineStatusTrackerManager.kt b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/LineStatusTrackerManager.kt index 16bfd834695a..749414d05527 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/LineStatusTrackerManager.kt +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/LineStatusTrackerManager.kt @@ -84,7 +84,7 @@ class LineStatusTrackerManager( private val trackers = HashMap() private val forcedDocuments = HashMap>() - private val partialChangeListsEnabled = Registry.`is`("vcs.enable.partial.changelists") + private var partialChangeListsEnabled = VcsConfiguration.getInstance(project).ENABLE_PARTIAL_CHANGELISTS && Registry.`is`("vcs.enable.partial.changelists") private val documentsInDefaultChangeList = HashSet() private val filesWithDamagedInactiveRanges = HashSet() @@ -115,14 +115,14 @@ class LineStatusTrackerManager( val editorFactory = EditorFactory.getInstance() editorFactory.addEditorFactoryListener(MyEditorFactoryListener(), disposable) - if (partialChangeListsEnabled) editorFactory.eventMulticaster.addDocumentListener(MyDocumentListener(), disposable) + editorFactory.eventMulticaster.addDocumentListener(MyDocumentListener(), disposable) changeListManager.addChangeListListener(MyChangeListListener()) val virtualFileManager = VirtualFileManager.getInstance() virtualFileManager.addVirtualFileListener(MyVirtualFileListener(), disposable) - if (partialChangeListsEnabled) CommandProcessor.getInstance().addCommandListener(MyCommandListener(), disposable) + CommandProcessor.getInstance().addCommandListener(MyCommandListener(), disposable) } } @@ -376,6 +376,29 @@ class LineStatusTrackerManager( } } + private fun updateTrackingModes() { + synchronized(LOCK) { + if (isDisposed) return + val mode = getTrackingMode() + val trackers = trackers.values.map { it.tracker } + for (tracker in trackers) { + val document = tracker.document + val virtualFile = tracker.virtualFile + + val isPartialTrackerExpected = canCreatePartialTrackerFor(virtualFile) + val isPartialTracker = tracker is PartialLocalLineStatusTracker + + if (isPartialTrackerExpected == isPartialTracker) { + tracker.mode = mode + } + else { + releaseTracker(document) + installTracker(virtualFile, document) + } + } + } + } + private fun getTrackingMode(): LineStatusTracker.Mode { val settings = VcsApplicationSettings.getInstance() if (!settings.SHOW_LST_GUTTER_MARKERS) return LineStatusTracker.Mode.SILENT @@ -590,6 +613,8 @@ class LineStatusTrackerManager( private inner class MyDocumentListener : DocumentListener { override fun documentChanged(event: DocumentEvent) { + if (!partialChangeListsEnabled) return + val document = event.document if (documentsInDefaultChangeList.contains(document)) return @@ -622,27 +647,9 @@ class LineStatusTrackerManager( private inner class MyLineStatusTrackerSettingListener : LineStatusTrackerSettingListener { override fun settingsUpdated() { - synchronized(LOCK) { - val mode = getTrackingMode() - for (data in trackers.values) { - val tracker = data.tracker - val document = tracker.document - val virtualFile = tracker.virtualFile + partialChangeListsEnabled = VcsConfiguration.getInstance(project).ENABLE_PARTIAL_CHANGELISTS && Registry.`is`("vcs.enable.partial.changelists") - if (tracker.mode == mode) continue - - val isPartialTrackerExpected = canCreatePartialTrackerFor(virtualFile) - val isPartialTracker = tracker is PartialLocalLineStatusTracker - - if (isPartialTrackerExpected == isPartialTracker) { - tracker.mode = mode - } - else { - releaseTracker(document) - installTracker(virtualFile, document) - } - } - } + updateTrackingModes() } } @@ -662,6 +669,8 @@ class LineStatusTrackerManager( private inner class MyCommandListener : CommandListener { override fun commandFinished(event: CommandEvent?) { + if (!partialChangeListsEnabled) return + if (CommandProcessor.getInstance().currentCommand == null && !filesWithDamagedInactiveRanges.isEmpty()) { showInactiveRangesDamagedNotification() diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsOptionsUsagesCollector.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsOptionsUsagesCollector.java index d8732fac4f11..831dc7de71d3 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsOptionsUsagesCollector.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsOptionsUsagesCollector.java @@ -71,6 +71,8 @@ public class VcsOptionsUsagesCollector extends AbstractProjectsUsagesCollector { usages.add(getBooleanUsage("include.text.into.shelf", configuration.INCLUDE_TEXT_INTO_SHELF)); usages.add(getBooleanUsage("check.conflicts.in.background", configuration.CHECK_LOCALLY_CHANGED_CONFLICTS_IN_BACKGROUND)); + usages.add(getBooleanUsage("enable.partial.changelists", configuration.ENABLE_PARTIAL_CHANGELISTS)); + return usages; } } diff --git a/plugins/git4idea/src/git4idea/GitVcs.java b/plugins/git4idea/src/git4idea/GitVcs.java index 68dd240ac070..0799361e8f42 100644 --- a/plugins/git4idea/src/git4idea/GitVcs.java +++ b/plugins/git4idea/src/git4idea/GitVcs.java @@ -438,6 +438,6 @@ public class GitVcs extends AbstractVcs { @Override public boolean arePartialChangelistsSupported() { - return Registry.is("vcs.enable.partial.changelists"); + return true; } }