mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
shelf: cleanup - move unused method to test, move test to another package
GitOrigin-RevId: ef711f238243e8a1552cdbb1f17dca3c68807b43
This commit is contained in:
committed by
intellij-monorepo-bot
parent
20344df577
commit
1dfcc9f433
+1
-19
@@ -331,26 +331,8 @@ public class ShelveChangesManager implements PersistentStateComponent<Element>,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be called only once: when Settings Repository plugin runs first time
|
||||
*
|
||||
* @return collection of non-migrated or not deleted files to show a error somewhere outside
|
||||
*/
|
||||
@NotNull
|
||||
public Collection<String> checkAndMigrateOldPatchResourcesToNewSchemeStorage() {
|
||||
Collection<String> nonMigratedPaths = new ArrayList<>();
|
||||
for (ShelvedChangeList list : mySchemeManager.getAllSchemes()) {
|
||||
File newPatchDir = new File(getShelfResourcesDirectory(), list.getName());
|
||||
// it should be enough for migration to check if resource directory exists. If any bugs appeared add isAncestor checks for each path
|
||||
if (!newPatchDir.exists() && newPatchDir.mkdirs()) {
|
||||
nonMigratedPaths.addAll(migrateResourcesTo(list, newPatchDir, true));
|
||||
}
|
||||
}
|
||||
return nonMigratedPaths;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Collection<String> migrateResourcesTo(@NotNull ShelvedChangeList list,
|
||||
static Collection<String> migrateResourcesTo(@NotNull ShelvedChangeList list,
|
||||
@NotNull File targetDirectory,
|
||||
boolean deleteOld) {
|
||||
Collection<String> nonMigratedPaths = new ArrayList<>();
|
||||
|
||||
+19
-18
@@ -1,32 +1,20 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.shelf;
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.vcs.changes.shelf;
|
||||
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vcs.VcsTestUtil;
|
||||
import com.intellij.openapi.vcs.changes.shelf.ShelveChangesManager;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.testFramework.PlatformTestCase;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static com.intellij.openapi.vcs.changes.shelf.ShelveChangesManager.migrateResourcesTo;
|
||||
|
||||
public class ShelveChangesManagerMigrationTest extends PlatformTestCase {
|
||||
|
||||
public void testMigrateInfo() throws Exception {
|
||||
@@ -70,10 +58,23 @@ public class ShelveChangesManagerMigrationTest extends PlatformTestCase {
|
||||
ShelveChangesManager shelveChangesManager = ShelveChangesManager.getInstance(myProject);
|
||||
shelveChangesManager.loadState(element);
|
||||
if (migrateResources) {
|
||||
shelveChangesManager.checkAndMigrateOldPatchResourcesToNewSchemeStorage();
|
||||
checkAndMigrateOldPatchResourcesToNewSchemeStorage(shelveChangesManager);
|
||||
}
|
||||
shelfDir.refresh(false, true);
|
||||
PlatformTestUtil.saveProject(myProject);
|
||||
PlatformTestUtil.assertDirectoriesEqual(afterDir, shelfDir);
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be called only once: when Settings Repository plugin runs first time
|
||||
*/
|
||||
private static void checkAndMigrateOldPatchResourcesToNewSchemeStorage(@NotNull ShelveChangesManager shelveChangesManager) {
|
||||
for (ShelvedChangeList list : shelveChangesManager.getAllLists()) {
|
||||
File newPatchDir = new File(shelveChangesManager.getShelfResourcesDirectory(), list.getName());
|
||||
// it should be enough for migration to check if resource directory exists. If any bugs appeared add isAncestor checks for each path
|
||||
if (!newPatchDir.exists() && newPatchDir.mkdirs()) {
|
||||
migrateResourcesTo(list, newPatchDir, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user