Merge remote-tracking branch 'origin/master'

This commit is contained in:
Roman Shevchenko
2016-09-25 18:18:45 +03:00
26 changed files with 191 additions and 171 deletions
@@ -225,11 +225,12 @@ fun getExportableComponentsMap(onlyExisting: Boolean,
}
}
val files = if (additionalExportFile == null) listOf(file) else if (isFileIncluded) listOf(file, additionalExportFile) else listOf(additionalExportFile)
val item = ExportableItem(files, if (computePresentableNames) getComponentPresentableName(stateAnnotation, aClass, pluginDescriptor) else "", storage.roamingType)
result.putValue(file, item)
val presentableName = if (computePresentableNames) getComponentPresentableName(stateAnnotation, aClass, pluginDescriptor) else ""
if (isFileIncluded) {
result.putValue(file, ExportableItem(listOf(file), presentableName, storage.roamingType))
}
if (additionalExportFile != null) {
result.putValue(additionalExportFile, item)
result.putValue(additionalExportFile, ExportableItem(listOf(additionalExportFile), presentableName, RoamingType.DEFAULT))
}
}
true
@@ -237,10 +238,10 @@ fun getExportableComponentsMap(onlyExisting: Boolean,
// must be in the end - because most of SchemeManager clients specify additionalExportFile in the State spec
(SchemeManagerFactory.getInstance() as SchemeManagerFactoryBase).process {
if (it.roamingType != RoamingType.DISABLED && it.presentableName != null && it.fileSpec.getOrNull(0) != '$') {
if (it.roamingType != RoamingType.DISABLED && it.fileSpec.getOrNull(0) != '$') {
val file = Paths.get(storageManager.expandMacros(ROOT_CONFIG), it.fileSpec)
if (!result.containsKey(file) && !isSkipFile(file)) {
result.putValue(file, ExportableItem(listOf(file), it.presentableName, it.roamingType))
result.putValue(file, ExportableItem(listOf(file), it.presentableName ?: "", it.roamingType))
}
}
}
@@ -129,13 +129,15 @@ internal class ApplicationStoreTest {
fun test(item: ExportableItem) {
val file = item.files.first()
assertThat(map[file]).containsExactly(item)
assertThat(map.get(file)).containsExactly(item)
assertThat(file).doesNotExist()
}
test(ExportableItem(listOf(Paths.get(optionsPath, "filetypes.xml"), Paths.get(rootConfigPath, "filetypes")), "File types", RoamingType.DEFAULT))
test(ExportableItem(listOf(Paths.get(optionsPath, "filetypes.xml")), "File types", RoamingType.DEFAULT))
test(ExportableItem(listOf(Paths.get(rootConfigPath, "filetypes")), "File types", RoamingType.DEFAULT))
test(ExportableItem(listOf(Paths.get(optionsPath, "customization.xml")), "Menus and toolbars customization", RoamingType.DEFAULT))
test(ExportableItem(listOf(Paths.get(optionsPath, "templates.xml"), Paths.get(rootConfigPath, "templates")), "Live templates", RoamingType.DEFAULT))
test(ExportableItem(listOf(Paths.get(optionsPath, "templates.xml")), "Live templates", RoamingType.DEFAULT))
test(ExportableItem(listOf(Paths.get(rootConfigPath, "templates")), "Live templates", RoamingType.DEFAULT))
}
@Test fun `import settings`() {
@@ -166,7 +168,6 @@ internal class ApplicationStoreTest {
val relativePaths = getPaths(ByteArrayInputStream(exportedData.internalBuffer, 0, exportedData.size()))
assertThat(relativePaths).containsOnly("a.xml", "foo/", "foo/bar.icls", "IntelliJ IDEA Global Settings")
val list = listOf(ExportableItem(listOf(componentFile, additionalFile), ""))
fun <B> Path.to(that: B) = MapEntry.entry(this, that)
@@ -174,7 +175,7 @@ internal class ApplicationStoreTest {
val componentKey = A::class.java.name
picoContainer.registerComponent(InstanceComponentAdapter(componentKey, component))
try {
assertThat(getExportableComponentsMap(false, false, storageManager, relativePaths)).containsOnly(componentFile.to(list), additionalFile.to(list))
assertThat(getExportableComponentsMap(false, false, storageManager, relativePaths)).containsOnly(componentFile.to(listOf(ExportableItem(listOf(componentFile), ""))), additionalFile.to(listOf(ExportableItem(listOf(additionalFile), ""))))
}
finally {
picoContainer.unregisterComponent(componentKey)
@@ -60,6 +60,7 @@ import com.intellij.vcs.log.VcsFullCommitDetails;
import com.intellij.vcsUtil.VcsImplUtil;
import com.intellij.vcsUtil.VcsUtil;
import org.intellij.images.editor.ImageFileEditor;
import org.jetbrains.annotations.CalledInAwt;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -165,6 +166,7 @@ public class DvcsUtil {
* Returns the currently selected file, based on which VcsBranch or StatusBar components will identify the current repository root.
*/
@Nullable
@CalledInAwt
public static VirtualFile getSelectedFile(@NotNull Project project) {
StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
final FileEditor fileEditor = StatusBarUtil.getCurrentFileEditor(project, statusBar);
@@ -328,6 +330,7 @@ public class DvcsUtil {
}
@Nullable
@CalledInAwt
public static <T extends Repository> T guessCurrentRepositoryQuick(@NotNull Project project,
@NotNull AbstractRepositoryManager<T> manager,
@Nullable String defaultRootPathValue) {
@@ -185,6 +185,7 @@ public abstract class DvcsStatusWidget<T extends Repository> extends EditorBased
}
@Nullable
@CalledInAwt
private String getToolTip(@NotNull Project project) {
T currentRepository = guessCurrentRepository(project);
if (currentRepository == null) return null;
@@ -64,7 +64,6 @@ import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.*;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.tree.IElementType;
@@ -138,7 +137,6 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
// Should be accessed in EDT only.
@SuppressWarnings("FieldAccessedSynchronizedAndUnsynchronized")
private boolean myDocumentClearing;
private int consoleTooMuchTextBufferRatio;
public Editor getEditor() {
return myEditor;
@@ -323,8 +321,6 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
myInputMessageFilter = null;
}
consoleTooMuchTextBufferRatio = Registry.intValue("console.too.much.text.buffer.ratio");
project.getMessageBus().connect(this).subscribe(DumbService.DUMB_MODE, new DumbService.DumbModeListener() {
private long myLastStamp;
@@ -786,10 +782,6 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
return myLastStickingToEnd;
}
private boolean isTheAmountOfTextTooBig(final int textLength) {
return myBuffer.isUseCyclicBuffer() && textLength > myBuffer.getCyclicBufferSize() / consoleTooMuchTextBufferRatio;
}
private void clearHyperlinkAndFoldings() {
myEditor.getMarkupModel().removeAllHighlighters();
@@ -26,7 +26,6 @@ import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.keymap.KeymapUtil;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
@@ -36,7 +35,6 @@ import com.intellij.ui.GuiUtils;
import com.intellij.ui.UIBundle;
import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.accessibility.ScreenReader;
import com.intellij.util.ui.update.LazyUiDisposable;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -131,42 +129,43 @@ public class ComponentWithBrowseButton<Comp extends JComponent> extends JPanel i
@Nullable Project project,
FileChooserDescriptor fileChooserDescriptor,
TextComponentAccessor<Comp> accessor) {
addBrowseFolderListener(title, description, project, fileChooserDescriptor, accessor, true);
addActionListener(new BrowseFolderActionListener<>(title, description, this, project, fileChooserDescriptor, accessor));
}
/**
* @deprecated use {@link #addBrowseFolderListener(String, String, Project, FileChooserDescriptor, TextComponentAccessor)} instead
*/
public void addBrowseFolderListener(@Nullable @Nls(capitalization = Nls.Capitalization.Title) String title,
@Nullable @Nls(capitalization = Nls.Capitalization.Sentence) String description,
@Nullable Project project,
FileChooserDescriptor fileChooserDescriptor,
TextComponentAccessor<Comp> accessor, boolean autoRemoveOnHide) {
addBrowseFolderListener(project, new BrowseFolderActionListener<>(title, description, this, project, fileChooserDescriptor, accessor), autoRemoveOnHide);
addBrowseFolderListener(title, description, project, fileChooserDescriptor, accessor);
}
/**
* @deprecated use {@link #addActionListener(ActionListener)} instead
*/
@SuppressWarnings("UnusedParameters")
public void addBrowseFolderListener(@Nullable Project project, final BrowseFolderActionListener<Comp> actionListener) {
addBrowseFolderListener(project, actionListener, true);
addActionListener(actionListener);
}
/**
* @deprecated use {@link #addActionListener(ActionListener)} instead
*/
@SuppressWarnings("UnusedParameters")
public void addBrowseFolderListener(@Nullable Project project, final BrowseFolderActionListener<Comp> actionListener, boolean autoRemoveOnHide) {
if (autoRemoveOnHide) {
new LazyUiDisposable<ComponentWithBrowseButton<Comp>>(null, this, this) {
@Override
protected void initialize(@NotNull Disposable parent, @NotNull ComponentWithBrowseButton<Comp> child, @Nullable Project project) {
addActionListener(actionListener);
Disposer.register(child, new Disposable() {
@Override
public void dispose() {
removeActionListener(actionListener);
}
});
}
};
} else {
addActionListener(actionListener);
}
addActionListener(actionListener);
}
@Override
public void dispose() { }
public void dispose() {
ActionListener[] listeners = myBrowseButton.getActionListeners();
for (ActionListener listener : listeners) {
myBrowseButton.removeActionListener(listener);
}
}
public FixedSizeButton getButton() {
return myBrowseButton;
@@ -0,0 +1,41 @@
/*
* Copyright 2000-2016 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.help.impl;
import com.intellij.openapi.application.ApplicationStarter;
import com.intellij.openapi.application.ex.ApplicationInfoEx;
/**
* @author Konstantin Bulenkov
*/
public class ShowProductVersion implements ApplicationStarter {
@Override
public String getCommandName() {
return "-version";
}
@Override
public void premain(String[] args) {
}
@SuppressWarnings("UseOfSystemOutOrSystemErr")
@Override
public void main(String[] args) {
System.out.println(ApplicationInfoEx.getInstanceEx().getFullVersion());
System.exit(0);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -102,12 +102,12 @@ public class IdeaApplication {
}
else {
Splash splash = null;
if (myArgs.length == 0) {
myStarter = getStarter();
if (myStarter instanceof IdeStarter) {
splash = ((IdeStarter)myStarter).showSplash(myArgs);
}
//if (myArgs.length == 0) {
myStarter = getStarter();
if (myStarter instanceof IdeStarter) {
splash = ((IdeStarter)myStarter).showSplash(myArgs);
}
//}
ApplicationManagerEx.createApplication(isInternal, isUnitTest, false, false, ApplicationManagerEx.IDEA_APPLICATION, splash);
}
@@ -16,7 +16,9 @@
package com.intellij.openapi.project.impl;
import com.intellij.ide.impl.ProjectUtil;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.JBProtocolCommand;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
@@ -34,7 +36,8 @@ public class JBProtocolOpenProjectCommand extends JBProtocolCommand {
@Override
public void perform(String target, Map<String, String> parameters) {
String path = URLDecoder.decode(target);
path = StringUtil.trimStart(path, LocalFileSystem.PROTOCOL_PREFIX);
ProjectUtil.openProject(path, null, true);
String projectPath = StringUtil.trimStart(path, LocalFileSystem.PROTOCOL_PREFIX);
ApplicationManager.getApplication().invokeLater(
() -> ProjectUtil.openProject(projectPath, null, true), ModalityState.NON_MODAL);
}
}
@@ -7,6 +7,7 @@
<appStarter implementation="com.intellij.help.impl.KeymapGenerator"/>
<appStarter implementation="com.intellij.help.impl.IntentionDump"/>
<appStarter implementation="com.intellij.help.impl.InspectionDump"/>
<appStarter implementation="com.intellij.help.impl.ShowProductVersion"/>
<applicationService serviceInterface="com.intellij.openapi.components.impl.stores.IComponentStore"
serviceImplementation="com.intellij.configurationStore.ApplicationStoreImpl"/>
@@ -33,6 +33,12 @@ public interface Promise<T> {
PENDING, FULFILLED, REJECTED
}
@NotNull
@Deprecated
static RuntimeException createError(@NotNull String error) {
return Promises.createError(error);
}
@NotNull
static <T> Promise<T> resolve(T result) {
return result == null ? Promises.resolvedPromise() : new DonePromise<>(result);
@@ -128,6 +128,7 @@ fun <T> collectResults(promises: List<Promise<T>>): Promise<List<T>> {
return all(promises, results)
}
@JvmOverloads
fun createError(error: String, log: Boolean = false): RuntimeException = MessageError(error, log)
inline fun <T> AsyncPromise<T>.compute(runnable: () -> T) {
@@ -606,12 +606,6 @@ emmet.segments.limit=50
emmet.template.length.limit.kilobytes=15
command.line.execution.timeout=30
console.ui.cycle.buffer.size=Default
console.too.much.text.buffer.ratio=10
console.too.much.text.buffer.ratio.description=Used for disabling of console processing (console filters for highlights, foldings...),\n\
when there is too much text to process.\n\
The ratio is used against the console cycle buffer size (idea.cycle.buffer.size/theRatio=maxTextLength).
ide.settings.keymap.input.method.enabled=false
ide.settings.keymap.input.method.enabled.description=Use input method instead of simple key event to enter shortcuts.
@@ -664,7 +658,6 @@ decompiler.dump.original.lines.description=Show original line numbers as comment
ide.transparency.mode.for.windows=false
ide.transparency.mode.for.windows.description=Allow to add transparency to floating windows
ide.new.welcome.screen=true
ide.new.welcome.screen.force=false
editor.caret.width=2
@@ -38,6 +38,7 @@ import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Splitter;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.ui.popup.PopupStep;
@@ -470,16 +471,18 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper {
protected JComponent createCenterPanel() {
if (myCenterPanel == null) {
myCenterPanel = new JPanel(new GridBagLayout());
final GridBagConstraints gb =
new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBUI.insets(1), 0, 0);
final GridBagConstraints centralGb = createConstraints();
myPatchFileLabel = new JLabel(VcsBundle.message("patch.apply.file.name.field"));
myPatchFileLabel.setLabelFor(myPatchFile);
myCenterPanel.add(myPatchFileLabel, gb);
myCenterPanel.add(myPatchFileLabel, centralGb);
gb.fill = GridBagConstraints.HORIZONTAL;
++gb.gridy;
myCenterPanel.add(myPatchFile, gb);
centralGb.fill = GridBagConstraints.HORIZONTAL;
++centralGb.gridy;
myCenterPanel.add(myPatchFile, centralGb);
JPanel treePanel = new JPanel(new GridBagLayout());
final GridBagConstraints gb = createConstraints();
final DefaultActionGroup group = new DefaultActionGroup();
final AnAction[] treeActions = myChangesTreeList.getTreeActions();
@@ -504,28 +507,37 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper {
}
final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("APPLY_PATCH", group, true);
++gb.gridy;
gb.fill = GridBagConstraints.HORIZONTAL;
myCenterPanel.add(toolbar.getComponent(), gb);
treePanel.add(toolbar.getComponent(), gb);
++gb.gridy;
gb.weighty = 1;
gb.fill = GridBagConstraints.BOTH;
myCenterPanel.add(ScrollPaneFactory.createScrollPane(myChangesTreeList), gb);
treePanel.add(ScrollPaneFactory.createScrollPane(myChangesTreeList), gb);
++gb.gridy;
gb.weighty = 0;
gb.fill = GridBagConstraints.NONE;
gb.insets.bottom = UIUtil.DEFAULT_VGAP;
myCenterPanel.add(myCommitLegendPanel.getComponent(), gb);
treePanel.add(myCommitLegendPanel.getComponent(), gb);
++gb.gridy;
gb.fill = GridBagConstraints.HORIZONTAL;
myCenterPanel.add(myChangeListChooser, gb);
Splitter splitter = new Splitter(true, 0.7f);
splitter.setFirstComponent(treePanel);
splitter.setSecondComponent(myChangeListChooser);
++centralGb.gridy;
centralGb.weighty = 1;
centralGb.fill = GridBagConstraints.BOTH;
myCenterPanel.add(splitter, centralGb);
}
return myCenterPanel;
}
@NotNull
private static GridBagConstraints createConstraints() {
return new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBUI.insets(1), 0, 0);
}
private void paintBusy(final boolean requestPut) {
if (requestPut) {
myChangesTreeList.setPaintBusy(true);
@@ -175,16 +175,18 @@ public abstract class NewEditChangelistPanel extends JPanel {
final Set<EditorCustomization> editorFeatures = ContainerUtil.newHashSet();
ContainerUtil.addIfNotNull(editorFeatures, SpellCheckingEditorCustomizationProvider.getInstance().getEnabledCustomization());
double scaleFactor = 1.3;
if (defaultLines == 1) {
editorFeatures.add(HorizontalScrollBarEditorCustomization.DISABLED);
editorFeatures.add(OneLineEditorCustomization.ENABLED);
} else {
}
else {
editorFeatures.add(SoftWrapsEditorCustomization.ENABLED);
scaleFactor = 2.1;
}
editorField = service.getEditorField(FileTypes.PLAIN_TEXT.getLanguage(), project, editorFeatures);
final int height = editorField.getFontMetrics(editorField.getFont()).getHeight();
editorField.getComponent().setMinimumSize(new Dimension(100, (int)(height * 1.3)));
editorField.getComponent().setMinimumSize(new Dimension(100, (int)(height * scaleFactor)));
return editorField;
}
@@ -62,7 +62,8 @@ public class GraphCommitCellRenderer extends ColoredTableCellRenderer {
@Override
public Dimension getPreferredSize() {
Dimension preferredSize = super.getPreferredSize();
return new Dimension(preferredSize.width + (myReferencePainter.isLeftAligned() ? 0 : myReferencePainter.getSize().width),
return new Dimension(preferredSize.width + (myReferencePainter.isLeftAligned() ? 0 :
myReferencePainter.getSize().width - LabelPainter.GRADIENT_WIDTH),
getPreferredHeight());
}
@@ -37,6 +37,7 @@ import git4idea.branch.GitBranchUtil;
import git4idea.i18n.GitBundle;
import git4idea.repo.GitRepository;
import git4idea.repo.GitRepositoryManager;
import org.jetbrains.annotations.CalledInAwt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -80,6 +81,7 @@ public abstract class GitRepositoryAction extends DumbAwareAction {
}
@NotNull
@CalledInAwt
private static VirtualFile getDefaultRoot(@NotNull Project project, @NotNull List<VirtualFile> roots, @Nullable VirtualFile[] vFiles) {
if (vFiles != null) {
for (VirtualFile file : vFiles) {
@@ -120,6 +122,7 @@ public abstract class GitRepositoryAction extends DumbAwareAction {
return true;
}
@CalledInAwt
protected static boolean isRebasing(AnActionEvent e) {
final Project project = e.getData(CommonDataKeys.PROJECT);
if (project != null) {
@@ -38,6 +38,7 @@ import git4idea.repo.GitRemote;
import git4idea.repo.GitRepository;
import git4idea.ui.branch.GitMultiRootBranchConfig;
import git4idea.validators.GitNewBranchNameValidator;
import org.jetbrains.annotations.CalledInAwt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -319,6 +320,7 @@ public class GitBranchUtil {
* or if the current Git root couldn't be determined.
*/
@Nullable
@CalledInAwt
public static GitRepository getCurrentRepository(@NotNull Project project) {
return getRepositoryOrGuess(project, DvcsUtil.getSelectedFile(project));
}
@@ -26,6 +26,7 @@ import git4idea.branch.GitBranchUtil;
import git4idea.config.GitVcsSettings;
import git4idea.repo.GitRepository;
import git4idea.repo.GitRepositoryChangeListener;
import org.jetbrains.annotations.CalledInAwt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -47,6 +48,7 @@ public class GitBranchWidget extends DvcsStatusWidget<GitRepository> {
@Nullable
@Override
@CalledInAwt
protected GitRepository guessCurrentRepository(@NotNull Project project) {
return DvcsUtil.guessCurrentRepositoryQuick(project, GitUtil.getRepositoryManager(project), mySettings.getRecentRootPath());
}
@@ -22,6 +22,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.CalledInAwt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.zmlx.hg4idea.repo.HgRepository;
@@ -45,6 +46,7 @@ public class HgActionUtil {
}
@Nullable
@CalledInAwt
public static HgRepository getSelectedRepositoryFromEvent(AnActionEvent e) {
final DataContext dataContext = e.getDataContext();
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
@@ -17,6 +17,7 @@ package org.zmlx.hg4idea.action;
import com.intellij.dvcs.repo.Repository;
import com.intellij.openapi.actionSystem.AnActionEvent;
import org.jetbrains.annotations.CalledInAwt;
import org.zmlx.hg4idea.repo.HgRepository;
public abstract class HgProcessStateAction extends HgAbstractGlobalSingleRepoAction {
@@ -26,6 +27,7 @@ public abstract class HgProcessStateAction extends HgAbstractGlobalSingleRepoAct
myState = state;
}
@CalledInAwt
protected boolean isRebasing(AnActionEvent e) {
HgRepository repository = HgActionUtil.getSelectedRepositoryFromEvent(e);
return repository != null && repository.getState() == myState;
@@ -22,6 +22,7 @@ import com.intellij.openapi.ui.popup.ListPopup;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.StatusBarWidget;
import com.intellij.util.ObjectUtils;
import org.jetbrains.annotations.CalledInAwt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.zmlx.hg4idea.HgProjectSettings;
@@ -52,6 +53,7 @@ public class HgStatusWidget extends DvcsStatusWidget<HgRepository> {
@Nullable
@Override
@CalledInAwt
protected HgRepository guessCurrentRepository(@NotNull Project project) {
return DvcsUtil.guessCurrentRepositoryQuick(project, HgUtil.getRepositoryManager(project),
HgProjectSettings.getInstance(project).getRecentRootPath());
@@ -25,7 +25,9 @@ import com.intellij.openapi.util.Couple;
import com.intellij.openapi.util.ShutDownTracker;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.*;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.FileStatus;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vcs.changes.ChangeListManager;
import com.intellij.openapi.vcs.changes.ContentRevision;
@@ -40,9 +42,9 @@ import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.GuiUtils;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.vcsUtil.VcsUtil;
import org.jetbrains.annotations.CalledInAwt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.zmlx.hg4idea.*;
@@ -112,39 +114,23 @@ public abstract class HgUtil {
VcsDirtyScopeManager.getInstance(project).dirDirtyRecursively(file);
}
public static void markFileDirty( final Project project, final VirtualFile file ) throws InvocationTargetException, InterruptedException {
ApplicationManager.getApplication().runReadAction(new Runnable() {
public void run() {
VcsDirtyScopeManager.getInstance(project).fileDirty(file);
}
});
runWriteActionAndWait(new Runnable() {
public void run() {
file.refresh(true, false);
}
});
public static void markFileDirty(final Project project, final VirtualFile file) throws InvocationTargetException, InterruptedException {
ApplicationManager.getApplication().runReadAction(() -> VcsDirtyScopeManager.getInstance(project).fileDirty(file));
runWriteActionAndWait(() -> file.refresh(true, false));
}
/**
* Runs the given task as a write action in the event dispatching thread and waits for its completion.
*/
public static void runWriteActionAndWait(@NotNull final Runnable runnable) throws InvocationTargetException, InterruptedException {
GuiUtils.runOrInvokeAndWait(new Runnable() {
public void run() {
ApplicationManager.getApplication().runWriteAction(runnable);
}
});
GuiUtils.runOrInvokeAndWait(() -> ApplicationManager.getApplication().runWriteAction(runnable));
}
/**
* Schedules the given task to be run as a write action in the event dispatching thread.
*/
public static void runWriteActionLater(@NotNull final Runnable runnable) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
public void run() {
ApplicationManager.getApplication().runWriteAction(runnable);
}
});
ApplicationManager.getApplication().invokeLater(() -> ApplicationManager.getApplication().runWriteAction(runnable));
}
/**
@@ -161,17 +147,11 @@ public abstract class HgUtil {
try {
final File file = copyResourceToTempFile(base, ".py");
final String fileName = file.getName();
ShutDownTracker.getInstance().registerShutdownTask(new Runnable() {
public void run() {
File[] files = file.getParentFile().listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.startsWith(fileName);
}
});
if (files != null) {
for (File file1 : files) {
file1.delete();
}
ShutDownTracker.getInstance().registerShutdownTask(() -> {
File[] files = file.getParentFile().listFiles((dir, name) -> name.startsWith(fileName));
if (files != null) {
for (File file1 : files) {
file1.delete();
}
}
});
@@ -203,7 +183,7 @@ public abstract class HgUtil {
* @param dir Directory which parent will be checked.
* @return Directory which is the nearest hg root being a parent of this directory,
* or <code>null</code> if this directory is not under hg.
* @see com.intellij.openapi.vcs.AbstractVcs#isVersionedDirectory(com.intellij.openapi.vfs.VirtualFile)
* @see com.intellij.openapi.vcs.AbstractVcs#isVersionedDirectory(VirtualFile)
*/
@Nullable
public static VirtualFile getNearestHgRoot(VirtualFile dir) {
@@ -227,7 +207,8 @@ public abstract class HgUtil {
/**
* Gets the Mercurial root for the given file path or null if non exists:
* the root should not only be in directory mappings, but also the .hg repository folder should exist.
* @see #getHgRootOrThrow(com.intellij.openapi.project.Project, com.intellij.openapi.vcs.FilePath)
*
* @see #getHgRootOrThrow(Project, FilePath)
*/
@Nullable
public static VirtualFile getHgRootOrNull(Project project, FilePath filePath) {
@@ -255,8 +236,8 @@ public abstract class HgUtil {
/**
* Gets the Mercurial root for the given file path or null if non exists:
* the root should not only be in directory mappings, but also the .hg repository folder should exist.
* @see #getHgRootOrThrow(com.intellij.openapi.project.Project, com.intellij.openapi.vcs.FilePath)
* @see #getHgRootOrNull(com.intellij.openapi.project.Project, com.intellij.openapi.vcs.FilePath)
* @see #getHgRootOrThrow(Project, FilePath)
* @see #getHgRootOrNull(Project, FilePath)
*/
@Nullable
public static VirtualFile getHgRootOrNull(Project project, @NotNull VirtualFile file) {
@@ -266,7 +247,7 @@ public abstract class HgUtil {
/**
* Gets the Mercurial root for the given file path or throws a VcsException if non exists:
* the root should not only be in directory mappings, but also the .hg repository folder should exist.
* @see #getHgRootOrNull(com.intellij.openapi.project.Project, com.intellij.openapi.vcs.FilePath)
* @see #getHgRootOrNull(Project, FilePath)
*/
@NotNull
public static VirtualFile getHgRootOrThrow(Project project, FilePath filePath) throws VcsException {
@@ -282,15 +263,6 @@ public abstract class HgUtil {
return getHgRootOrThrow(project, VcsUtil.getFilePath(file.getPath()));
}
@Nullable
public static VirtualFile getRootForSelectedFile(@NotNull Project project) {
VirtualFile selectedFile = DvcsUtil.getSelectedFile(project);
if (selectedFile != null) {
return getHgRootOrNull(project, selectedFile);
}
return null;
}
/**
* Shows a message dialog to enter the name of new branch.
*
@@ -373,19 +345,6 @@ public abstract class HgUtil {
}
}
/**
* Returns all HG roots in the project.
*/
public static @NotNull List<VirtualFile> getHgRepositories(@NotNull Project project) {
final List<VirtualFile> repos = new LinkedList<>();
for (VcsRoot root : ProjectLevelVcsManager.getInstance(project).getAllVcsRoots()) {
if (HgVcs.VCS_NAME.equals(root.getVcs().getName())) {
repos.add(root.getPath());
}
}
return repos;
}
@NotNull
public static Map<VirtualFile, Collection<VirtualFile>> sortByHgRoots(@NotNull Project project, @NotNull Collection<VirtualFile> files) {
Map<VirtualFile, Collection<VirtualFile>> sorted = new HashMap<>();
@@ -474,7 +433,7 @@ public abstract class HgUtil {
Collection<HgChange> hgChanges = statusCommand.executeInCurrentThread(root, Collections.singleton(path));
List<Change> changes = new ArrayList<>();
//convert output changes to standart Change class
//convert output changes to standard Change class
for (HgChange hgChange : hgChanges) {
FileStatus status = convertHgDiffStatus(hgChange.getStatus());
if (status != FileStatus.UNKNOWN) {
@@ -540,6 +499,7 @@ public abstract class HgUtil {
}
@Nullable
@CalledInAwt
public static HgRepository getCurrentRepository(@NotNull Project project) {
if (project.isDisposed()) return null;
return DvcsUtil.guessRepositoryForFile(project, getRepositoryManager(project),
@@ -667,11 +627,6 @@ public abstract class HgUtil {
@NotNull
public static List<String> getTargetNames(@NotNull HgRepository repository) {
return ContainerUtil.sorted(ContainerUtil.map(repository.getRepositoryConfig().getPaths(), new Function<String, String>() {
@Override
public String fun(String s) {
return removePasswordIfNeeded(s);
}
}));
return ContainerUtil.<String>sorted(ContainerUtil.map(repository.getRepositoryConfig().getPaths(), s -> removePasswordIfNeeded(s)));
}
}
+12 -18
View File
@@ -24,6 +24,7 @@ import com.intellij.openapi.application.PathManager
import com.intellij.openapi.components.RoamingType
import com.intellij.openapi.components.stateStore
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.diagnostic.catchAndLog
import com.intellij.openapi.progress.runBackgroundableTask
import com.intellij.openapi.project.Project
import com.intellij.openapi.project.impl.ProjectLifecycleListener
@@ -216,39 +217,32 @@ class IcsApplicationLoadListener : ApplicationLoadListener {
icsManager = IcsManager(pluginSystemDir)
if (!pluginSystemDir.exists()) {
try {
LOG.catchAndLog {
val oldPluginDir = Paths.get(PathManager.getSystemPath(), "settingsRepository")
if (oldPluginDir.exists()) {
oldPluginDir.move(pluginSystemDir)
}
}
catch (e: Throwable) {
LOG.error(e)
}
}
val repositoryManager = icsManager.repositoryManager
if (repositoryManager.isRepositoryExists() && repositoryManager is GitRepositoryManager) {
val osFolderName = getOsFolderName()
val migrateSchemes = repositoryManager.renameDirectory(linkedMapOf(
Pair("\$ROOT_CONFIG$", null),
Pair("_mac/\$ROOT_CONFIG$", "_mac"),
Pair("_windows/\$ROOT_CONFIG$", "_windows"),
Pair("_linux/\$ROOT_CONFIG$", "_linux"),
Pair("_freebsd/\$ROOT_CONFIG$", "_freebsd"),
Pair("_unix/\$ROOT_CONFIG$", "_unix"),
Pair("_unknown/\$ROOT_CONFIG$", "_unknown"),
Pair("$osFolderName/\$ROOT_CONFIG$", osFolderName),
Pair("\$APP_CONFIG$", null),
Pair("_mac/\$APP_CONFIG$", "_mac"),
Pair("_windows/\$APP_CONFIG$", "_windows"),
Pair("_linux/\$APP_CONFIG$", "_linux"),
Pair("_freebsd/\$APP_CONFIG$", "_freebsd"),
Pair("_unix/\$APP_CONFIG$", "_unix"),
Pair("_unknown/\$APP_CONFIG$", "_unknown")
))
Pair("$osFolderName/\$APP_CONFIG$", osFolderName)
), "Get rid of \$ROOT_CONFIG$ and \$APP_CONFIG")
val migrateKeyMaps = repositoryManager.renameDirectory(linkedMapOf(
Pair("$osFolderName/keymaps", "keymaps")
), "Move keymaps to root")
val removeOtherXml = repositoryManager.delete("other.xml")
if (migrateSchemes || removeOtherXml) {
if (migrateSchemes || migrateKeyMaps || removeOtherXml) {
// schedule push to avoid merge conflicts
application.invokeLater({ icsManager.autoSyncManager.autoSync(force = true) })
}
@@ -21,7 +21,7 @@ import com.intellij.openapi.util.SystemInfo
internal const val PROJECTS_DIR_NAME: String = "_projects/"
private val osPrefixes = arrayOf("_mac/", "_windows/", "_linux/", "_freebsd/", "_unix/")
private fun getOsFolderName() = when {
internal fun getOsFolderName() = when {
SystemInfo.isMac -> "_mac"
SystemInfo.isWindows -> "_windows"
SystemInfo.isLinux -> "_linux"
@@ -16,6 +16,7 @@
package org.jetbrains.settingsRepository.git
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.diagnostic.catchAndLog
import com.intellij.openapi.progress.EmptyProgressIndicator
import com.intellij.openapi.progress.ProgressIndicator
import com.intellij.openapi.util.ShutDownTracker
@@ -37,7 +38,7 @@ import org.eclipse.jgit.transport.*
import org.jetbrains.settingsRepository.*
import org.jetbrains.settingsRepository.RepositoryManager.Updater
import java.io.IOException
import java.nio.file.Files
import java.nio.file.FileAlreadyExistsException
import java.nio.file.Path
import kotlin.concurrent.write
@@ -229,7 +230,7 @@ class GitRepositoryManager(private val credentialsStore: Lazy<IcsCredentialsStor
override fun canCommit() = repository.repositoryState.canCommit()
fun renameDirectory(pairs: Map<String, String?>): Boolean {
fun renameDirectory(pairs: Map<String, String?>, commitMessage: String): Boolean {
var addCommand: AddCommand? = null
val toDelete = SmartList<DeleteDirectory>()
for ((oldPath, newPath) in pairs) {
@@ -242,31 +243,31 @@ class GitRepositoryManager(private val credentialsStore: Lazy<IcsCredentialsStor
old.directoryStreamIfExists {
val new = if (newPath == null) dir else dir.resolve(newPath)
for (file in it) {
try {
LOG.catchAndLog {
if (file.isHidden()) {
file.delete()
}
else {
Files.move(file, new.resolve(file.fileName))
try {
file.move(new.resolve(file.fileName))
}
catch (ignored: FileAlreadyExistsException) {
return@catchAndLog
}
if (addCommand == null) {
addCommand = AddCommand(repository)
}
addCommand!!.addFilepattern(if (newPath == null) file.fileName.toString() else "$newPath/${file.fileName}")
}
}
catch (e: Throwable) {
LOG.error(e)
}
}
toDelete.add(DeleteDirectory(oldPath))
}
try {
LOG.catchAndLog {
old.delete()
}
catch (e: Throwable) {
LOG.error(e)
}
}
if (toDelete.isEmpty() && addCommand == null) {
@@ -278,7 +279,7 @@ class GitRepositoryManager(private val credentialsStore: Lazy<IcsCredentialsStor
addCommand!!.call()
}
repository.commit(with(IdeaCommitMessageFormatter()) { StringBuilder().appendCommitOwnerInfo(true) }.append("Get rid of \$ROOT_CONFIG$ and \$APP_CONFIG").toString())
repository.commit(with(IdeaCommitMessageFormatter()) { StringBuilder().appendCommitOwnerInfo(true) }.append(commitMessage).toString())
return true
}