Search in sources :

Example 1 with VcsRef

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

the class FileHistoryFilterer method getCurrentRow.

private int getCurrentRow(@NotNull DataPack pack, @NotNull VisibleGraph<Integer> visibleGraph, @NotNull IndexDataGetter.FileNamesData fileIndexData) {
    PermanentGraph<Integer> permanentGraph = pack.getPermanentGraph();
    if (permanentGraph instanceof PermanentGraphImpl) {
        CompressedRefs refs = pack.getRefsModel().getAllRefsByRoot().get(myRoot);
        Optional<VcsRef> headOptional = refs.streamBranches().filter(br -> br.getName().equals("HEAD")).findFirst();
        if (headOptional.isPresent()) {
            VcsRef head = headOptional.get();
            assert head.getRoot().equals(myRoot);
            return findAncestorRowAffectingFile((PermanentGraphImpl<Integer>) permanentGraph, head.getCommitHash(), visibleGraph, fileIndexData);
        }
    }
    return -1;
}
Also used : CompressedRefs(com.intellij.vcs.log.data.CompressedRefs) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VisiblePack(com.intellij.vcs.log.visible.VisiblePack) DataPack(com.intellij.vcs.log.data.DataPack) ContainerUtil(com.intellij.util.containers.ContainerUtil) ReachableNodes(com.intellij.vcs.log.graph.impl.facade.ReachableNodes) VcsLogFilterer(com.intellij.vcs.log.visible.VcsLogFilterer) PermanentGraphImpl(com.intellij.vcs.log.graph.impl.facade.PermanentGraphImpl) Stack(com.intellij.util.containers.Stack) VisibleGraph(com.intellij.vcs.log.graph.VisibleGraph) VcsLogData(com.intellij.vcs.log.data.VcsLogData) LinearGraph(com.intellij.vcs.log.graph.api.LinearGraph) VisibleGraphImpl(com.intellij.vcs.log.graph.impl.facade.VisibleGraphImpl) FilePath(com.intellij.openapi.vcs.FilePath) VcsUtil(com.intellij.vcsUtil.VcsUtil) LinearGraphUtils(com.intellij.vcs.log.graph.utils.LinearGraphUtils) Set(java.util.Set) PermanentCommitsInfoImpl(com.intellij.vcs.log.graph.impl.permanent.PermanentCommitsInfoImpl) VcsRef(com.intellij.vcs.log.VcsRef) DfsUtil(com.intellij.vcs.log.graph.utils.DfsUtil) VcsLogFilterCollection(com.intellij.vcs.log.VcsLogFilterCollection) Nullable(org.jetbrains.annotations.Nullable) Hash(com.intellij.vcs.log.Hash) IndexDataGetter(com.intellij.vcs.log.data.index.IndexDataGetter) PermanentGraph(com.intellij.vcs.log.graph.PermanentGraph) Optional(java.util.Optional) ObjectUtils(com.intellij.util.ObjectUtils) NotNull(org.jetbrains.annotations.NotNull) Ref(com.intellij.openapi.util.Ref) Collections(java.util.Collections) VcsRef(com.intellij.vcs.log.VcsRef) CompressedRefs(com.intellij.vcs.log.data.CompressedRefs) PermanentGraphImpl(com.intellij.vcs.log.graph.impl.facade.PermanentGraphImpl)

Example 2 with VcsRef

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

the class SimpleRefGroup method buildGroups.

public static void buildGroups(@NotNull MultiMap<VcsRefType, VcsRef> groupedRefs, boolean compact, boolean showTagNames, @NotNull List<RefGroup> result) {
    if (groupedRefs.isEmpty())
        return;
    if (compact) {
        VcsRef firstRef = ObjectUtils.assertNotNull(ContainerUtil.getFirstItem(groupedRefs.values()));
        RefGroup group = ContainerUtil.getFirstItem(result);
        if (group == null) {
            result.add(new SimpleRefGroup(firstRef.getType().isBranch() || showTagNames ? firstRef.getName() : "", ContainerUtil.newArrayList(groupedRefs.values())));
        } else {
            group.getRefs().addAll(groupedRefs.values());
        }
    } else {
        for (Map.Entry<VcsRefType, Collection<VcsRef>> entry : groupedRefs.entrySet()) {
            if (entry.getKey().isBranch()) {
                for (VcsRef ref : entry.getValue()) {
                    result.add(new SimpleRefGroup(ref.getName(), ContainerUtil.newArrayList(ref)));
                }
            } else {
                result.add(new SimpleRefGroup(showTagNames ? ObjectUtils.notNull(ContainerUtil.getFirstItem(entry.getValue())).getName() : "", ContainerUtil.newArrayList(entry.getValue())));
            }
        }
    }
}
Also used : VcsRefType(com.intellij.vcs.log.VcsRefType) VcsRef(com.intellij.vcs.log.VcsRef) MultiMap(com.intellij.util.containers.MultiMap) RefGroup(com.intellij.vcs.log.RefGroup)

Example 3 with VcsRef

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

the class GitBranchComparatorTest method check.

private void check(@NotNull String expectedBest, @NotNull Collection<VcsRef> givenBranches) throws IOException {
    VcsRef actualBest = getTheMostPowerfulRef(givenBranches);
    assertEquals(expect(expectedBest).get(0), actualBest);
}
Also used : VcsRef(com.intellij.vcs.log.VcsRef)

Example 4 with VcsRef

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

the class GitRefManagerTest method given.

@NotNull
protected Collection<VcsRef> given(@NotNull String... refs) throws IOException {
    Collection<VcsRef> result = ContainerUtil.newArrayList();
    cd(myProjectRoot);
    Hash hash = HashImpl.build(git("rev-parse HEAD"));
    for (String refName : refs) {
        if (isHead(refName)) {
            result.add(ref(hash, "HEAD", GitRefManager.HEAD));
        } else if (isRemoteBranch(refName)) {
            git("update-ref refs/remotes/" + refName + " " + hash.asString());
            result.add(ref(hash, refName, GitRefManager.REMOTE_BRANCH));
        } else if (isTag(refName)) {
            git("update-ref " + refName + " " + hash.asString());
            result.add(ref(hash, GitBranchUtil.stripRefsPrefix(refName), GitRefManager.TAG));
        } else {
            git("update-ref refs/heads/" + refName + " " + hash.asString());
            result.add(ref(hash, refName, GitRefManager.LOCAL_BRANCH));
        }
    }
    setUpTracking(result);
    myRepo.update();
    return result;
}
Also used : VcsRef(com.intellij.vcs.log.VcsRef) Hash(com.intellij.vcs.log.Hash) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with VcsRef

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

the class RefParser method parseCommitRefs.

// e25b7d8f (HEAD, refs/remotes/origin/master, refs/remotes/origin/HEAD, refs/heads/master)
public List<VcsRef> parseCommitRefs(@NotNull String input, @NotNull VirtualFile root) {
    int firstSpaceIndex = input.indexOf(' ');
    if (firstSpaceIndex < 0) {
        return Collections.emptyList();
    }
    String strHash = input.substring(0, firstSpaceIndex);
    Hash hash = HashImpl.build(strHash);
    String refPaths = input.substring(firstSpaceIndex + 2, input.length() - 1);
    String[] longRefPaths = refPaths.split("(, )|( -> )");
    List<VcsRef> refs = new ArrayList<>();
    for (String longRefPatch : longRefPaths) {
        VcsRef ref = createRef(hash, longRefPatch, root);
        if (ref != null) {
            refs.add(ref);
        }
    }
    return refs;
}
Also used : VcsRef(com.intellij.vcs.log.VcsRef) ArrayList(java.util.ArrayList) Hash(com.intellij.vcs.log.Hash)

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