Search in sources :

Example 6 with VcsRef

use of com.intellij.vcs.log.VcsRef in project intellij-community by JetBrains.

the class CompressedRefs method refsToCommit.

@NotNull
SmartList<VcsRef> refsToCommit(int index) {
    SmartList<VcsRef> result = new SmartList<>();
    if (myBranches.containsKey(index))
        result.addAll(myBranches.get(index));
    TIntArrayList tags = myTags.get(index);
    if (tags != null) {
        tags.forEach(value -> {
            result.add(myStorage.getVcsRef(value));
            return true;
        });
    }
    return result;
}
Also used : VcsRef(com.intellij.vcs.log.VcsRef) SmartList(com.intellij.util.SmartList) TIntArrayList(gnu.trove.TIntArrayList) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with VcsRef

use of com.intellij.vcs.log.VcsRef in project intellij-community by JetBrains.

the class SnapshotVisiblePackBuilder method createRefsModel.

private RefsModel createRefsModel(@NotNull RefsModel refsModel, @NotNull Set<Integer> heads, @NotNull VisibleGraph<Integer> visibleGraph, @NotNull Map<VirtualFile, VcsLogProvider> providers) {
    Set<VcsRef> branchesAndHeads = ContainerUtil.newHashSet();
    refsModel.getBranches().stream().filter(ref -> {
        int index = myStorage.getCommitIndex(ref.getCommitHash(), ref.getRoot());
        Integer row = visibleGraph.getVisibleRowIndex(index);
        return row != null && row >= 0;
    }).forEach(branchesAndHeads::add);
    heads.stream().flatMap(head -> refsModel.refsToCommit(head).stream()).forEach(branchesAndHeads::add);
    Map<VirtualFile, Set<VcsRef>> map = VcsLogUtil.groupRefsByRoot(branchesAndHeads);
    Map<VirtualFile, CompressedRefs> refs = ContainerUtil.newHashMap();
    for (VirtualFile root : providers.keySet()) {
        Set<VcsRef> refsForRoot = map.get(root);
        refs.put(root, new CompressedRefs(refsForRoot == null ? ContainerUtil.newHashSet() : refsForRoot, myStorage));
    }
    return new RefsModel(refs, heads, myStorage, providers);
}
Also used : com.intellij.vcs.log.data(com.intellij.vcs.log.data) VcsLogUtil(com.intellij.vcs.log.impl.VcsLogUtil) VirtualFile(com.intellij.openapi.vfs.VirtualFile) BaseController(com.intellij.vcs.log.graph.impl.facade.BaseController) Set(java.util.Set) VcsLogProvider(com.intellij.vcs.log.VcsLogProvider) ContainerUtil(com.intellij.util.containers.ContainerUtil) VcsRef(com.intellij.vcs.log.VcsRef) CollapsedController(com.intellij.vcs.log.graph.collapsing.CollapsedController) VcsLogFilterCollection(com.intellij.vcs.log.VcsLogFilterCollection) VisibleGraph(com.intellij.vcs.log.graph.VisibleGraph) GraphColorManagerImpl(com.intellij.vcs.log.graph.GraphColorManagerImpl) Map(java.util.Map) PermanentGraphInfo(com.intellij.vcs.log.graph.api.permanent.PermanentGraphInfo) VisibleGraphImpl(com.intellij.vcs.log.graph.impl.facade.VisibleGraphImpl) NotNull(org.jetbrains.annotations.NotNull) VirtualFile(com.intellij.openapi.vfs.VirtualFile) Set(java.util.Set) VcsRef(com.intellij.vcs.log.VcsRef)

Example 8 with VcsRef

use of com.intellij.vcs.log.VcsRef in project intellij-community by JetBrains.

the class SimpleRefGroup method getColors.

@NotNull
public static List<Color> getColors(@NotNull Collection<VcsRef> refs) {
    MultiMap<VcsRefType, VcsRef> referencesByType = ContainerUtil.groupBy(refs, VcsRef::getType);
    if (referencesByType.size() == 1) {
        Map.Entry<VcsRefType, Collection<VcsRef>> firstItem = ObjectUtils.assertNotNull(ContainerUtil.getFirstItem(referencesByType.entrySet()));
        boolean multiple = firstItem.getValue().size() > 1;
        Color color = firstItem.getKey().getBackgroundColor();
        return multiple ? Arrays.asList(color, color) : Collections.singletonList(color);
    } else {
        List<Color> colorsList = ContainerUtil.newArrayList();
        for (VcsRefType type : referencesByType.keySet()) {
            if (referencesByType.get(type).size() > 1) {
                colorsList.add(type.getBackgroundColor());
            }
            colorsList.add(type.getBackgroundColor());
        }
        return colorsList;
    }
}
Also used : VcsRefType(com.intellij.vcs.log.VcsRefType) VcsRef(com.intellij.vcs.log.VcsRef) MultiMap(com.intellij.util.containers.MultiMap) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with VcsRef

use of com.intellij.vcs.log.VcsRef in project intellij-community by JetBrains.

the class ReferencesPanel method update.

public void update() {
    removeAll();
    int height = getIconHeight();
    JBLabel firstLabel = null;
    for (Map.Entry<VcsRefType, Collection<VcsRef>> typeAndRefs : myGroupedVisibleReferences.entrySet()) {
        VcsRefType type = typeAndRefs.getKey();
        Collection<VcsRef> refs = typeAndRefs.getValue();
        int refIndex = 0;
        for (VcsRef reference : refs) {
            Icon icon = createIcon(type, refs, refIndex, height);
            String ending = (refIndex != refs.size() - 1) ? "," : "";
            String text = reference.getName() + ending;
            JBLabel label = createLabel(text, icon);
            if (firstLabel == null) {
                firstLabel = label;
                add(label);
            } else {
                addWrapped(label, firstLabel);
            }
            refIndex++;
        }
    }
    if (getHiddenReferencesSize() > 0) {
        JBLabel label = createRestLabel(getHiddenReferencesSize());
        addWrapped(label, ObjectUtils.assertNotNull(firstLabel));
    }
    setVisible(!myGroupedVisibleReferences.isEmpty());
    revalidate();
    repaint();
}
Also used : VcsRefType(com.intellij.vcs.log.VcsRefType) VcsRef(com.intellij.vcs.log.VcsRef) JBLabel(com.intellij.ui.components.JBLabel) Collection(java.util.Collection) LabelIcon(com.intellij.vcs.log.ui.render.LabelIcon) Map(java.util.Map) MultiMap(com.intellij.util.containers.MultiMap)

Example 10 with VcsRef

use of com.intellij.vcs.log.VcsRef in project intellij-community by JetBrains.

the class GitRefManagerTest method setUpTracking.

private void setUpTracking(@NotNull Collection<VcsRef> refs) {
    cd(myProjectRoot);
    for (final VcsRef ref : refs) {
        if (ref.getType() == GitRefManager.LOCAL_BRANCH) {
            final String localBranch = ref.getName();
            if (ContainerUtil.exists(refs, new Condition<VcsRef>() {

                @Override
                public boolean value(VcsRef remoteRef) {
                    return remoteRef.getType() == GitRefManager.REMOTE_BRANCH && remoteRef.getName().replace("origin/", "").equals(localBranch);
                }
            })) {
                git("config branch." + localBranch + ".remote origin");
                git("config branch." + localBranch + ".merge refs/heads/" + localBranch);
            }
        }
    }
}
Also used : VcsRef(com.intellij.vcs.log.VcsRef)

Aggregations

VcsRef (com.intellij.vcs.log.VcsRef)10 NotNull (org.jetbrains.annotations.NotNull)5 MultiMap (com.intellij.util.containers.MultiMap)3 Hash (com.intellij.vcs.log.Hash)3 VcsRefType (com.intellij.vcs.log.VcsRefType)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 ContainerUtil (com.intellij.util.containers.ContainerUtil)2 VcsLogFilterCollection (com.intellij.vcs.log.VcsLogFilterCollection)2 VisibleGraph (com.intellij.vcs.log.graph.VisibleGraph)2 VisibleGraphImpl (com.intellij.vcs.log.graph.impl.facade.VisibleGraphImpl)2 Map (java.util.Map)2 Set (java.util.Set)2 Ref (com.intellij.openapi.util.Ref)1 FilePath (com.intellij.openapi.vcs.FilePath)1 JBLabel (com.intellij.ui.components.JBLabel)1 ObjectUtils (com.intellij.util.ObjectUtils)1 SmartList (com.intellij.util.SmartList)1 Stack (com.intellij.util.containers.Stack)1 RefGroup (com.intellij.vcs.log.RefGroup)1 VcsLogProvider (com.intellij.vcs.log.VcsLogProvider)1