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;
}
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);
}
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;
}
}
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();
}
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);
}
}
}
}
Aggregations