[log] Expose VcsLogRefs into API

* For now just return branches, since it is all what's needed.
* Keep getRefsModel() until it is decided what methods should be exposed
This commit is contained in:
Kirill Likhodedov
2014-03-10 20:05:02 +04:00
parent 3d8130382b
commit d282a0ed73
4 changed files with 45 additions and 4 deletions
@@ -25,4 +25,7 @@ public interface VcsLogDataPack {
@NotNull
Map<VirtualFile, VcsLogProvider> getLogProviders();
@NotNull
VcsLogRefs getRefs();
}
@@ -0,0 +1,33 @@
/*
* 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;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
/**
* Collection of {@link VcsRef branches & tags references} which are in the log.
*/
public interface VcsLogRefs {
/**
* Returns all branches.
*/
@NotNull
Collection<VcsRef> getBranches();
}
@@ -75,6 +75,12 @@ public class DataPack implements VcsLogDataPack {
return myGraphFacade;
}
@NotNull
@Override
public VcsLogRefs getRefs() {
return myRefsModel;
}
@NotNull
public RefsModel getRefsModel() {
return myRefsModel;
@@ -6,6 +6,7 @@ import com.intellij.util.SmartList;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.MultiMap;
import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.VcsLogRefs;
import com.intellij.vcs.log.VcsRef;
import gnu.trove.TIntObjectHashMap;
import org.jetbrains.annotations.NotNull;
@@ -14,10 +15,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
/**
* @author erokhins
*/
public class RefsModel {
public class RefsModel implements VcsLogRefs {
@NotNull private final Collection<VcsRef> myBranches;
@NotNull private final MultiMap<Hash, VcsRef> myRefsToHashes;
@@ -80,6 +78,7 @@ public class RefsModel {
return myRefsToIndices.containsKey(index) ? myRefsToIndices.get(index) : Collections.<VcsRef>emptyList();
}
@Override
@NotNull
public Collection<VcsRef> getBranches() {
return myBranches;