diff options
Diffstat (limited to 'platform/vcs-log/impl/src/com/intellij/vcs/log')
5 files changed, 41 insertions, 25 deletions
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphColorManagerImpl.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphColorManagerImpl.java index c14ee206c954..ec74038a66e4 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphColorManagerImpl.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/graph/GraphColorManagerImpl.java @@ -26,8 +26,7 @@ import com.intellij.vcs.log.VcsRef; import com.intellij.vcs.log.data.RefsModel; import org.jetbrains.annotations.NotNull; -import java.util.Collection; -import java.util.Map; +import java.util.*; public class GraphColorManagerImpl implements GraphColorManager<Integer> { @@ -59,7 +58,7 @@ public class GraphColorManagerImpl implements GraphColorManager<Integer> { if (isEmptyRefs(refs, headCommit)) { return DEFAULT_COLOR; } - VcsRef firstRef = getRefManager(refs).sort(refs).get(0); + VcsRef firstRef = ContainerUtil.sorted(refs, getRefManager(refs).getComparator()).get(0); // TODO dark variant return firstRef.getName().hashCode(); } @@ -94,28 +93,36 @@ public class GraphColorManagerImpl implements GraphColorManager<Integer> { return 0; } if (firstEmpty) { - return -1; + return 1; } if (secondEmpty) { - return 1; + return -1; } VcsLogRefManager refManager1 = getRefManager(refs1); VcsLogRefManager refManager2 = getRefManager(refs2); - if (!refManager1.equals(refManager2)) { + if (!refManager1.equals(refManager2)) { // heads from different VCSs are not comparable => are considered equal for now return 0; } - Map<VcsRef, Boolean> positions = ContainerUtil.newHashMap(); - for (VcsRef ref : refs1) { - positions.put(ref, true); + Comparator<VcsRef> comparator = refManager1.getComparator(); + Iterator<VcsRef> it1 = ContainerUtil.sorted(refs1, comparator).iterator(); + Iterator<VcsRef> it2 = ContainerUtil.sorted(refs2, comparator).iterator(); + while (it1.hasNext() && it2.hasNext()) { + VcsRef ref1 = it1.next(); + VcsRef ref2 = it2.next(); + int compare = comparator.compare(ref1, ref2); + if (compare != 0) { + return compare; + } } - for (VcsRef ref : refs2) { - positions.put(ref, false); + if (it1.hasNext()) { + return -1; } - - VcsRef firstRef = refManager1.sort(positions.keySet()).get(0); - return positions.get(firstRef) ? 1 : -1; + if (it2.hasNext()) { + return 1; + } + return 0; } @NotNull diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/StructureFilterPopupComponent.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/StructureFilterPopupComponent.java index 3ac9464002bc..c134b1aa330d 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/StructureFilterPopupComponent.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/StructureFilterPopupComponent.java @@ -32,7 +32,6 @@ import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.List; class StructureFilterPopupComponent extends FilterPopupComponent<VcsLogStructureFilter> { @@ -89,13 +88,7 @@ class StructureFilterPopupComponent extends FilterPopupComponent<VcsLogStructure return tooltip; } - @NotNull - private static <T> Collection<T> notNullize(@Nullable Collection<T> items) { - return items != null ? items : Collections.<T>emptyList(); - } - private class SelectAction extends DumbAwareAction { - SelectAction() { super("Select..."); } @@ -108,7 +101,7 @@ class StructureFilterPopupComponent extends FilterPopupComponent<VcsLogStructure new ArrayList<VirtualFile>(myRoots)); if (chooser.showAndGet()) { myFiles.clear(); - myFiles.addAll(notNullize(chooser.getSelectedFiles())); + myFiles.addAll(ContainerUtil.notNullize(chooser.getSelectedFiles())); setValue(myFiles); applyFilters(); } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java index d963bb3aedaa..dc876657c428 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java @@ -11,6 +11,7 @@ import com.intellij.ui.ScrollPaneFactory; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBLoadingPanel; import com.intellij.ui.components.JBTextField; +import com.intellij.util.containers.ContainerUtil; import com.intellij.util.text.DateFormatUtil; import com.intellij.util.ui.AsyncProcessIcon; import com.intellij.util.ui.UIUtil; @@ -146,7 +147,7 @@ class DetailsPanel extends JPanel implements ListSelectionListener { @NotNull private List<VcsRef> sortRefs(@NotNull Hash hash, @NotNull VirtualFile root) { Collection<VcsRef> refs = myDataPack.getRefsModel().refsToCommit(hash); - return myLogDataHolder.getLogProvider(root).getReferenceManager().sort(refs); + return ContainerUtil.sorted(refs, myLogDataHolder.getLogProvider(root).getReferenceManager().getComparator()); } private static class DataPanel extends JEditorPane { diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java index 11e9c843fc60..f033f752e1ec 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java @@ -1,3 +1,18 @@ +/* + * 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.ui.frame; import com.intellij.ide.CopyProvider; @@ -175,7 +190,7 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C } @Override - protected void paintComponent(Graphics g) { + protected void paintComponent(@NotNull Graphics g) { if (myRepaintFreezedCounter.get() > 0) { return; } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/AbstractPaddingCellRender.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/AbstractPaddingCellRender.java index 973252db6af6..23c736b4420b 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/AbstractPaddingCellRender.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/AbstractPaddingCellRender.java @@ -107,7 +107,7 @@ public abstract class AbstractPaddingCellRender extends ColoredTableCellRenderer return Collections.emptyMap(); } VirtualFile root = refs.iterator().next().getRoot(); // all refs are from the same commit => they have the same root - refs = myDataHolder.getLogProvider(root).getReferenceManager().sort(refs); + refs = ContainerUtil.sorted(refs, myDataHolder.getLogProvider(root).getReferenceManager().getComparator()); List<VcsRef> branches = getBranches(refs); Collection<VcsRef> tags = ContainerUtil.subtract(refs, branches); return getLabelsForRefs(branches, tags); |