Merge remote-tracking branch 'origin/master'

This commit is contained in:
Dmitry Trofimov
2014-08-05 18:31:49 +02:00
10 changed files with 502 additions and 168 deletions
@@ -466,7 +466,7 @@ public class Javac2 extends Javac {
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
classfileVersion[0] = version;
}
}, 0);
}, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
return classfileVersion[0];
}
@@ -35,22 +35,22 @@ import java.awt.*;
import java.util.ArrayList;
import java.util.List;
public class UserRenderersConfigurable implements ConfigurableUi<NodeRendererSettings> {
public final class UserRenderersConfigurable extends JPanel implements ConfigurableUi<NodeRendererSettings> {
private static final Icon ADD_ICON = IconUtil.getAddIcon();
private static final Icon REMOVE_ICON = IconUtil.getRemoveIcon();
private static final Icon COPY_ICON = PlatformIcons.COPY_ICON;
private static final Icon UP_ICON = IconUtil.getMoveUpIcon();
private static final Icon DOWN_ICON = IconUtil.getMoveDownIcon();
private JPanel myNameFieldPanel;
private JTextField myNameField;
private final JPanel myNameFieldPanel;
private final JTextField myNameField;
private ElementsChooser<NodeRenderer> myRendererChooser;
private NodeRenderer myCurrentRenderer = null;
private final CompoundRendererConfigurable myRendererDataConfigurable = new CompoundRendererConfigurable();
@Override
@NotNull
public JComponent getComponent() {
public UserRenderersConfigurable() {
super(new BorderLayout(4, 0));
JPanel left = new JPanel(new BorderLayout());
left.add(createToolbar(), BorderLayout.NORTH);
left.add(createRenderersList(), BorderLayout.CENTER);
@@ -75,10 +75,14 @@ public class UserRenderersConfigurable implements ConfigurableUi<NodeRendererSet
}
});
JPanel panel = new JPanel(new BorderLayout(4, 0));
panel.add(left, BorderLayout.WEST);
panel.add(center, BorderLayout.CENTER);
return panel;
add(left, BorderLayout.WEST);
add(center, BorderLayout.CENTER);
}
@Override
@NotNull
public JComponent getComponent() {
return this;
}
private JComponent createRenderersList() {
@@ -228,8 +232,8 @@ public class UserRenderersConfigurable implements ConfigurableUi<NodeRendererSet
@Override
public void update(AnActionEvent e) {
super.update(e);
final Presentation presentation = e.getPresentation();
presentation.setEnabled(myRendererChooser.getSelectedElement() != null);
e.getPresentation().setEnabled(myRendererChooser.getSelectedElement() != null);
}
}
@@ -242,16 +246,14 @@ public class UserRenderersConfigurable implements ConfigurableUi<NodeRendererSet
public void actionPerformed(AnActionEvent e) {
final NodeRenderer selectedElement = myRendererChooser.getSelectedElement();
if (selectedElement != null) {
final NodeRenderer cloned = (NodeRenderer)selectedElement.clone();
myRendererChooser.addElement(cloned, true);
myRendererChooser.addElement((NodeRenderer)selectedElement.clone(), true);
}
}
@Override
public void update(AnActionEvent e) {
super.update(e);
final Presentation presentation = e.getPresentation();
presentation.setEnabled(myRendererChooser.getSelectedElement() != null);
e.getPresentation().setEnabled(myRendererChooser.getSelectedElement() != null);
}
}
@@ -284,8 +286,7 @@ public class UserRenderersConfigurable implements ConfigurableUi<NodeRendererSet
@Override
public void update(AnActionEvent e) {
super.update(e);
final Presentation presentation = e.getPresentation();
presentation.setEnabled(myRendererChooser.getSelectedElement() != null);
e.getPresentation().setEnabled(myRendererChooser.getSelectedElement() != null);
}
}
}
@@ -136,7 +136,11 @@ public abstract class JavaPostfixTemplatesUtils {
@Contract("null -> false")
public static boolean isNotPrimitiveTypeExpression(@Nullable PsiExpression expression) {
return expression != null && expression.getType() != null && !(expression.getType() instanceof PsiPrimitiveType);
if (expression == null) {
return false;
}
PsiType type = expression.getType();
return type != null && !(type instanceof PsiPrimitiveType);
}
@Contract("null -> false")
@@ -144,7 +144,7 @@ public abstract class ClassProcessingBuilder extends ModuleLevelBuilder {
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
result.set(version);
}
}, 0);
}, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
return result.get();
}
@@ -101,7 +101,7 @@ public class VcsLogJoiner<CommitId, Commit extends GraphCommit<CommitId>> {
searchHashes.remove(commit.getId());
}
if (searchHashes.size() != 0)
throw new IllegalStateException(ILLEGAL_DATA_RELOAD_ALL);
throw new VcsLogRefreshNotEnoughDataException();
return lastIndex;
}
@@ -153,7 +153,7 @@ public class VcsLogJoiner<CommitId, Commit extends GraphCommit<CommitId>> {
private void markRealRedNode(@NotNull CommitId node) {
if (!currentRed.remove(node))
throw new VcsLogRefreshNotEnoughDataException();
throw new IllegalStateException(ILLEGAL_DATA_RELOAD_ALL); // never happened
allRedCommit.add(node);
}
@@ -173,7 +173,7 @@ public class VcsLogJoiner<CommitId, Commit extends GraphCommit<CommitId>> {
if (currentRed.isEmpty())
return lastIndex + 1;
}
throw new IllegalStateException(ILLEGAL_DATA_RELOAD_ALL);
throw new IllegalStateException(ILLEGAL_DATA_RELOAD_ALL); // see VcsLogJoinerTest#illegalStateExceptionTest
}
public Set<CommitId> getAllRedCommit() {
@@ -377,7 +377,7 @@ public class VcsLogRefresherImpl implements VcsLogRefresher {
LOG.error(e); // collecting information : how often this situation happens, do we need to try to load more or can safely reload all
}
catch (IllegalStateException e) {
LOG.info(e);
LOG.error(e);
}
return null;
}
@@ -1,141 +0,0 @@
package com.intellij.vcs.log.data;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.TimedCommitParser;
import com.intellij.vcs.log.TimedVcsCommit;
import com.intellij.vcs.log.impl.HashImpl;
import org.junit.Test;
import java.util.Collection;
import java.util.List;
import static java.util.Arrays.asList;
import static org.junit.Assert.assertEquals;
/**
* @author Kirill Likhodedov
*/
public class VcsLogJoinerTest {
public void runTest(List<String> initial, List<String> updateBlock, List<String> oldRefs, List<String> newRefs, String expected) {
List<TimedVcsCommit> savedLog = TimedCommitParser.log(ArrayUtil.toStringArray(initial));
List<? extends TimedVcsCommit> firstBlock = TimedCommitParser.log(ArrayUtil.toStringArray(updateBlock));
Collection<Hash> vcsOldRefs = ContainerUtil.map(oldRefs, new Function<String, Hash>() {
@Override
public Hash fun(String s) {
return HashImpl.build(s);
}
});
Collection<Hash> vcsNewRefs = ContainerUtil.map(newRefs, new Function<String, Hash>() {
@Override
public Hash fun(String s) {
return HashImpl.build(s);
}
});
List<? extends TimedVcsCommit> result = new VcsLogJoiner<Hash, TimedVcsCommit>().addCommits(savedLog, vcsOldRefs, firstBlock, vcsNewRefs).getFirst();
assertEquals(expected, toStr(result));
}
@Test
public void simpleTest() {
runTest(
asList("4|-a2|-a1", "3|-b1|-a", "2|-a1|-a", "1|-a|-"),
asList("5|-f|-b1", "6|-e|-a2"),
asList("a2", "b1"),
asList("f", "e"),
"e, f, a2, b1, a1, a"
);
}
@Test
public void oneNodeTest() {
runTest(
asList("3|-a1|-"),
asList("3|-a1|-"),
asList("a1"),
asList("a1"),
"a1"
);
}
@Test
public void oneNodeResetTest() {
runTest(
asList("3|-a1|-a2", "2|-a2|-"),
asList("2|-a2|-"),
asList("a2", "a1"),
asList("a2"),
"a2"
);
}
@Test
public void oneNodeReset2Test() {
runTest(
asList("3|-a1|-a2", "2|-a2|-"),
asList("2|-a2|-"),
asList("a1"),
asList("a2"),
"a2"
);
}
@Test
public void simpleRemoveCommitsTest() {
runTest(
asList("4|-a2|-a1", "3|-b1|-a", "2|-a1|-a", "1|-a|-"),
asList("5|-f|-b1", "6|-e|-a1"),
asList("a2"),
asList("f", "e"),
"e, f, b1, a1, a"
);
}
@Test
public void removeCommitsTest() {
runTest(
asList("5|-a5|-a4", "4|-a4|-a2 a3", "3|-a3|-a1", "2|-a2|-a1", "1|-a1|-"),
asList("6|-a6|-a3"),
asList("a5"),
asList("a6"),
"a6, a3, a1"
);
}
@Test
public void removeCommitsTest2() {
runTest(
asList("2|-a2|-a1", "1|-a1|-"),
asList("5|-a5|-a4", "3|-a3|-a2", "4|-a4|-a3"),
asList("a2"),
asList("a5"),
"a5, a4, a3, a2, a1"
);
}
@Test
public void removeCommitsTest3() {
runTest(
asList("3|-a3|-a2", "2|-a2|-a1", "1|-a1|-"),
asList("2|-a2|-a1"),
asList("a3"),
asList("a2"),
"a2, a1"
);
}
private static String toStr(List<? extends TimedVcsCommit> commits) {
StringBuilder s = new StringBuilder();
for (TimedVcsCommit commit : commits) {
if (s.length() != 0) {
s.append(", ");
}
s.append(commit.getId().asString());
}
return s.toString();
}
}
@@ -0,0 +1,468 @@
/*
* Copyright 2000-2014 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.vcs.log.data
import org.junit.Test
import java.util.ArrayList
import com.intellij.vcs.log.TimedCommitParser
import com.intellij.util.ArrayUtil
import com.intellij.vcs.log.impl.HashImpl
import com.intellij.vcs.log.TimedVcsCommit
import com.intellij.vcs.log.Hash
import org.junit.Assert.*
class VcsLogJoinerTest {
class StringArrayBuilder() {
val result = ArrayList<String>()
fun String.plus() = result.add(this)
fun Collection<String>.plus() = result.addAll(this)
}
class TestRunner() {
private var fullLog: List<String>? = null
private var recentCommits: List<String>? = null
private var oldRefs: List<String>? = null
private var newRefs: List<String>? = null
private var expected: String? = null
private fun build(f: StringArrayBuilder.() -> Unit): List<String> {
val stringArrayBuilder = StringArrayBuilder()
stringArrayBuilder.f()
return stringArrayBuilder.result
}
fun fullLog(f: StringArrayBuilder.() -> Unit) {fullLog = build(f)}
fun recentCommits(f: StringArrayBuilder.() -> Unit) {recentCommits = build(f)}
fun oldRefs(f: StringArrayBuilder.() -> Unit) {oldRefs = build(f)}
fun newRefs(f: StringArrayBuilder.() -> Unit) {newRefs = build(f)}
fun expected(f: StringArrayBuilder.() -> Unit) {expected = build(f).join(separator = "\n")}
fun run() {
val vcsFullLog = TimedCommitParser.log(fullLog!!)
val vcsRecentCommits = TimedCommitParser.log(recentCommits!!)
val vcsOldRefs = oldRefs!!.map { HashImpl.build(it) }
val vcsNewRefs = newRefs!!.map { HashImpl.build(it) }
val result = VcsLogJoiner<Hash, TimedVcsCommit>().addCommits(vcsFullLog, vcsOldRefs, vcsRecentCommits, vcsNewRefs).getFirst()!!
val actual = result.map { it.getId().asString() }.join(separator = "\n")
assertEquals(expected, actual)
}
}
fun runTest(f: TestRunner.() -> Unit) {
val testRunner = TestRunner()
testRunner.f()
testRunner.run()
}
val BIG_TIME = 100000000
Test fun simple() {
runTest {
fullLog {
+"4|-a2|-a1"
+"3|-b1|-a"
+"2|-a1|-a"
+"1|-a|-"
}
recentCommits {
+"5|-f|-b1"
+"6|-e|-a2"
}
oldRefs {
+"a2"
+"b1"
}
newRefs {
+"f"
+"e"
}
expected {
+"e"
+"f"
+"a2"
+"b1"
+"a1"
+"a"
}
}
}
Test fun oneNode() {
runTest {
fullLog {
+"3|-a1|-"
}
recentCommits {
+"3|-a1|-"
}
oldRefs {
+"a1"
}
newRefs {
+"a1"
}
expected {
+"a1"
}
}
}
Test fun oneNodeReset() {
runTest {
fullLog {
+"3|-a1|-a2"
+"2|-a2|-"
}
recentCommits {
+"2|-a2|-"
}
oldRefs {
+"a2"
+"a1"
}
newRefs {
+"a2"
}
expected {
+"a2"
}
}
}
Test fun oneNodeReset2() {
runTest {
fullLog {
+"3|-a1|-a2"
+"2|-a2|-"
}
recentCommits {
+"2|-a2|-"
}
oldRefs {
+"a1"
}
newRefs {
+"a2"
}
expected {
+"a2"
}
}
}
Test fun simpleRemoveCommits() {
runTest {
fullLog {
+"4|-a2|-a1"
+"3|-b1|-a"
+"2|-a1|-a"
+"1|-a|-"
}
recentCommits {
+"5|-f|-b1"
+"6|-e|-a1"
}
oldRefs {
+"a2"
}
newRefs {
+"f"
+"e"
}
expected {
+"e"
+"f"
+"b1"
+"a1"
+"a"
}
}
}
Test fun removeCommits() {
runTest {
fullLog {
+"5|-a5|-a4"
+"4|-a4|-a2 a3"
+"3|-a3|-a1"
+"2|-a2|-a1"
+"1|-a1|-"
}
recentCommits {
+"6|-a6|-a3"
}
oldRefs {
+"a5"
}
newRefs {
+"a6"
}
expected {
+"a6"
+"a3"
+"a1"
}
}
}
Test fun removeCommits2() {
runTest {
fullLog {
+"2|-a2|-a1"
+"1|-a1|-"
}
recentCommits {
+"5|-a5|-a4"
+"3|-a3|-a2"
+"4|-a4|-a3"
}
oldRefs {
+"a2"
}
newRefs {
+"a5"
}
expected {
+"a5"
+"a4"
+"a3"
+"a2"
+"a1"
}
}
}
Test fun removeCommits3() {
runTest {
fullLog {
+"3|-a3|-a2"
+"2|-a2|-a1"
+"1|-a1|-"
}
recentCommits {
+"2|-a2|-a1"
}
oldRefs {
+"a3"
}
newRefs {
+"a2"
}
expected {
+"a2"
+"a1"
}
}
}
Test fun removeOldBranch() {
runTest {
fullLog {
+"100|-e1|-e10"
+(10..100000).map { "${BIG_TIME - it}|-e${it}|-e${it + 1}" }
+"5|-e100001|-a1"
+"4|-b2|-b1"
+"3|-b1|-a1"
+"1|-a1|-"
}
recentCommits {
+"100|-e1|-e10"
}
oldRefs {
+"e1"
+"b2"
}
newRefs {
"e1"
}
expected {
+"e1"
+(10..100000).map { "e$it" }
+"e100001"
+"a1"
}
}
}
Test fun addToOldBranch() {
runTest {
fullLog {
+"100|-e1|-e10"
+(10..100000).map { "${BIG_TIME - it}|-e${it}|-e${it + 1}" }
+"5|-e100001|-a1"
+"4|-b2|-b1"
+"3|-b1|-a1"
+"1|-a1|-"
}
recentCommits {
+"50|-b4|-b3"
+"49|-b3|-b2"
}
oldRefs {
+"e1"
+"b2"
}
newRefs {
+"e1"
+"b4"
}
expected {
+"e1"
+(10..100000).map { "e$it" }
+"b4"
+"b3"
+"e100001"
+"b2"
+"b1"
+"a1"
}
}
}
Test fun removeLongBranch() {
runTest {
fullLog {
+"100|-e1|-e10"
+(10..100000).map { "${BIG_TIME - it}|-e${it}|-e${it + 1}" }
+"5|-e100001|-a1"
+"4|-b2|-b1"
+"3|-b1|-a1"
+"1|-a1|-"
}
recentCommits {
+"50|-b4|-b3"
+"49|-b3|-b2"
}
oldRefs {
+"e1"
+"b2"
}
newRefs {
+"b4"
}
expected {
+"b4"
+"b3"
+"b2"
+"b1"
+"a1"
}
}
}
Test fun notEnoughDataExceptionTest() {
try {
runTest {
fullLog {
+"1|-a1|-"
}
recentCommits {
+"3|-a3|-a2"
}
oldRefs {
+"a1"
}
newRefs {
+"a3"
}
}
} catch (e: VcsLogRefreshNotEnoughDataException) {
return
}
fail()
}
Test fun illegalStateExceptionTest() {
try {
runTest {
fullLog {
+"1|-a1|-"
}
recentCommits {
+"1|-a1|-"
}
oldRefs {
+"a1"
+"a2"
}
newRefs {
+"a1"
}
}
} catch (e: IllegalStateException) {
return
}
fail()
}
Test fun removeParallelBranch() {
runTest {
fullLog {
+"4|-a4|-a1"
+"3|-a3|-a2"
+"2|-a2|-"
+"1|-a1|-"
}
recentCommits {
}
oldRefs {
+"a4"
+"a3"
}
newRefs {
+"a3"
}
expected {
+"a3"
+"a2"
}
}
}
Test fun removeAll() {
runTest {
fullLog {
+"4|-a4|-a1"
+"3|-a3|-a2"
+"2|-a2|-"
+"1|-a1|-"
}
recentCommits {
}
oldRefs {
+"a4"
+"a3"
}
newRefs {
}
expected {
}
}
}
}
+1
View File
@@ -21,6 +21,7 @@
<orderEntry type="module" module-name="spellchecker" />
<orderEntry type="module" module-name="vcs-log-graph-api" />
<orderEntry type="module" module-name="testFramework" scope="TEST" />
<orderEntry type="library" scope="TEST" name="KotlinJavaRuntime" level="project" />
</component>
</module>
+3 -2
View File
@@ -20,6 +20,8 @@ import static org.jetbrains.jps.idea.IdeaProjectLoader.guessHome
setProperty("home", guessHome(this as Script))
includeTargets << new File("${guessHome(this as Script)}/build/scripts/utils.gant")
// signMacZip locates in ultimate_utils.gant
includeTargets << new File("${guessHome(this)}/build/scripts/ultimate_utils.gant")
includeTargets << new File("${guessHome(this)}/build/scripts/libLicenses.gant")
requireProperty("buildNumber", requireProperty("build.number", snapshot))
@@ -137,8 +139,7 @@ target('default': "Build artifacts") {
// "${pythonEduHome}/build/strings.nsi", "${pythonEduHome}/build/paths.nsi",
// "pycharm", false, true, ".py", system_selector)
def extraArgs = ["build.code": "pycharmEDU-${buildName}", "build.number": "PE-$buildNumber", "artifacts.path": "${paths.artifacts}"]
def extraArgs = ["build.code": "pycharmEDU-${buildNumber}", "build.number": "PE-$buildNumber", "artifacts.path": "${paths.artifacts}"]
signMacZip("pycharm", extraArgs)
buildDmg("pycharm", "${pythonEduHome}/build/DMG_background.png", extraArgs)