mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 06:51:17 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.data;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import com.intellij.vcs.log.Hash;
|
||||
import com.intellij.vcs.log.graph.elements.Node;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Responsible for identifying commits which are displayed around the selected commit in the log table. <br/>
|
||||
* This is needed to be able to smartly get commit details from the VCS in a batch.
|
||||
*
|
||||
* @param <CommitId> Commit identifier, which can be, for example, a {@link Hash} or an {@link Integer} or a {@link Node}.
|
||||
*/
|
||||
public interface AroundProvider<CommitId> {
|
||||
|
||||
/**
|
||||
* Returns commits which are located around the given commit in the log table.<br/>
|
||||
* The returned map must include the commit which was requested originally.<br/>
|
||||
* Commits must be grouped by repository roots.
|
||||
*
|
||||
* @param id currently selected commit id.
|
||||
* @param above number of commits to look above (later, by date) the given commit.
|
||||
* @param below number of commits to look below (before, by date) the given commit.
|
||||
* @return hashes of commits located around the given one, grouped by repository roots.
|
||||
*/
|
||||
@NotNull
|
||||
MultiMap<VirtualFile, Hash> getCommitsAround(@NotNull CommitId id, int above, int below);
|
||||
|
||||
/**
|
||||
* Returns the Hash of the commit identified by the given CommitId.
|
||||
*/
|
||||
@NotNull
|
||||
Hash resolveId(@NotNull CommitId id);
|
||||
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.vcs.log.Hash;
|
||||
import com.intellij.vcs.log.VcsLogProvider;
|
||||
import com.intellij.vcs.log.VcsShortCommitDetails;
|
||||
import com.intellij.vcs.log.ui.tables.AbstractVcsLogTableModel;
|
||||
import com.intellij.vcs.log.util.SequentialLimitedLifoExecutor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -79,15 +80,18 @@ public abstract class DataGetter<T extends VcsShortCommitDetails> implements Dis
|
||||
myLoadingFinishedListeners.clear();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public <CommitId> T getCommitData(@NotNull CommitId id, @NotNull AroundProvider<CommitId> aroundProvider) {
|
||||
@Nullable
|
||||
public <CommitId> T getCommitData(int row, @NotNull AbstractVcsLogTableModel<?, CommitId> tableModel) {
|
||||
assert EventQueue.isDispatchThread();
|
||||
Hash hash = aroundProvider.resolveId(id);
|
||||
Hash hash = tableModel.getHashAtRow(row);
|
||||
if (hash == null) {
|
||||
return null;
|
||||
}
|
||||
T details = getFromCache(hash);
|
||||
if (details != null) {
|
||||
return details;
|
||||
}
|
||||
runLoadAroundCommitData(id, aroundProvider);
|
||||
runLoadAroundCommitData(row, tableModel);
|
||||
return myCache.get(hash); // now it is in the cache as "Loading Details".
|
||||
}
|
||||
|
||||
@@ -112,9 +116,9 @@ public abstract class DataGetter<T extends VcsShortCommitDetails> implements Dis
|
||||
return (T)myDataHolder.getTopCommitDetails(hash);
|
||||
}
|
||||
|
||||
private <CommitId> void runLoadAroundCommitData(@NotNull CommitId id, @NotNull AroundProvider<CommitId> aroundProvider) {
|
||||
private <CommitId> void runLoadAroundCommitData(int row, @NotNull AbstractVcsLogTableModel<?, CommitId> tableModel) {
|
||||
long taskNumber = myCurrentTaskIndex++;
|
||||
MultiMap<VirtualFile, Hash> commits = aroundProvider.getCommitsAround(id, UP_PRELOAD_COUNT, DOWN_PRELOAD_COUNT);
|
||||
MultiMap<VirtualFile, Hash> commits = getCommitsAround(row, tableModel, UP_PRELOAD_COUNT, DOWN_PRELOAD_COUNT);
|
||||
for (Map.Entry<VirtualFile, Collection<Hash>> hashesByRoots : commits.entrySet()) {
|
||||
VirtualFile root = hashesByRoots.getKey();
|
||||
Collection<Hash> hashes = hashesByRoots.getValue();
|
||||
@@ -132,6 +136,21 @@ public abstract class DataGetter<T extends VcsShortCommitDetails> implements Dis
|
||||
myLoader.queue(task);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static <CommitId> MultiMap<VirtualFile, Hash> getCommitsAround(int selectedRow,
|
||||
@NotNull AbstractVcsLogTableModel<?, CommitId> model,
|
||||
int above, int below) {
|
||||
MultiMap<VirtualFile, Hash> commits = MultiMap.create();
|
||||
for (int row = Math.max(0, selectedRow - above); row < selectedRow + below && row < model.getRowCount(); row++) {
|
||||
Hash hash = model.getHashAtRow(row);
|
||||
if (hash != null) {
|
||||
VirtualFile root = model.getRoot(row);
|
||||
commits.putValue(root, hash);
|
||||
}
|
||||
}
|
||||
return commits;
|
||||
}
|
||||
|
||||
private void preLoadCommitData(@NotNull MultiMap<VirtualFile, Hash> commits) throws VcsException {
|
||||
for (Map.Entry<VirtualFile, Collection<Hash>> entry : commits.entrySet()) {
|
||||
List<String> hashStrings = ContainerUtil.map(entry.getValue(), new Function<Hash, String>() {
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.data;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import com.intellij.vcs.log.Hash;
|
||||
import com.intellij.vcs.log.graph.Graph;
|
||||
import com.intellij.vcs.log.graph.elements.Node;
|
||||
import com.intellij.vcs.log.graph.elements.NodeRow;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class NodeAroundProvider implements AroundProvider<Node> {
|
||||
|
||||
@NotNull private final DataPack myDataPack;
|
||||
@NotNull private final VcsLogDataHolder myDataHolder;
|
||||
|
||||
public NodeAroundProvider(@NotNull DataPack pack, @NotNull VcsLogDataHolder dataHolder) {
|
||||
myDataPack = pack;
|
||||
myDataHolder = dataHolder;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public MultiMap<VirtualFile, Hash> getCommitsAround(@NotNull Node node, int above, int below) {
|
||||
MultiMap<VirtualFile, Hash> commits = MultiMap.create();
|
||||
int rowIndex = node.getRowIndex();
|
||||
for (int i = rowIndex - above; i < rowIndex + below; i++) {
|
||||
Node commitNode = getCommitNodeInRow(i);
|
||||
if (commitNode != null) {
|
||||
Hash hash = myDataHolder.getHash(commitNode.getCommitIndex());
|
||||
commits.putValue(commitNode.getBranch().getRepositoryRoot(), hash);
|
||||
}
|
||||
}
|
||||
return commits;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Hash resolveId(@NotNull Node node) {
|
||||
return myDataHolder.getHash(node.getCommitIndex());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Node getCommitNodeInRow(int rowIndex) {
|
||||
Graph graph = myDataPack.getGraphModel().getGraph();
|
||||
if (rowIndex < 0 || rowIndex >= graph.getNodeRows().size()) {
|
||||
return null;
|
||||
}
|
||||
NodeRow row = graph.getNodeRows().get(rowIndex);
|
||||
for (Node node : row.getNodes()) {
|
||||
if (node.getType() == Node.NodeType.COMMIT_NODE || node.getType() == Node.NodeType.END_COMMIT_NODE) {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -69,7 +69,7 @@ public class VcsLogFilterer {
|
||||
// apply details filters, and use simple table without graph (we can't filter by details and keep the graph yet).
|
||||
final AbstractVcsLogTableModel model;
|
||||
if (!detailsFilters.isEmpty()) {
|
||||
List<VcsFullCommitDetails> filteredCommits = filterByDetails(dataPack, graphModel, detailsFilters);
|
||||
List<VcsFullCommitDetails> filteredCommits = filterByDetails(graphModel, detailsFilters);
|
||||
model = new NoGraphTableModel(myUI, filteredCommits, dataPack.getRefsModel(), LoadMoreStage.INITIAL);
|
||||
}
|
||||
else {
|
||||
@@ -147,18 +147,17 @@ public class VcsLogFilterer {
|
||||
});
|
||||
}
|
||||
|
||||
private List<VcsFullCommitDetails> filterByDetails(DataPack dataPack, final GraphModel graphModel,
|
||||
final List<VcsLogDetailsFilter> detailsFilters) {
|
||||
@NotNull
|
||||
private List<VcsFullCommitDetails> filterByDetails(@NotNull GraphModel graphModel, @NotNull List<VcsLogDetailsFilter> detailsFilters) {
|
||||
List<VcsFullCommitDetails> result = ContainerUtil.newArrayList();
|
||||
int topCommits = myLogDataHolder.getSettings().getRecentCommitsCount();
|
||||
NodeAroundProvider nodeAroundProvider = new NodeAroundProvider(dataPack, myLogDataHolder);
|
||||
for (int i = 0; i < topCommits && i < graphModel.getGraph().getNodeRows().size(); i++) {
|
||||
Node node = graphModel.getGraph().getCommitNodeInRow(i);
|
||||
if (node == null) {
|
||||
// there can be nodes which contain no commits (IDEA-115442, branch filter case)
|
||||
continue;
|
||||
}
|
||||
final VcsFullCommitDetails details = getDetailsFromCache(node, nodeAroundProvider);
|
||||
final VcsFullCommitDetails details = getDetailsFromCache(node);
|
||||
if (details == null) {
|
||||
// Details for recent commits should be available in the cache.
|
||||
// However if they are not there for some reason, we stop filtering.
|
||||
@@ -184,12 +183,12 @@ public class VcsLogFilterer {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private VcsFullCommitDetails getDetailsFromCache(@NotNull final Node node, @NotNull final NodeAroundProvider nodeAroundProvider) {
|
||||
private VcsFullCommitDetails getDetailsFromCache(@NotNull final Node node) {
|
||||
final Ref<VcsFullCommitDetails> ref = Ref.create();
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ref.set(myLogDataHolder.getCommitDetailsGetter().getCommitData(node, nodeAroundProvider));
|
||||
ref.set(myLogDataHolder.getCommitDetailsGetter().getCommitDataIfAvailable(myLogDataHolder.getHash(node.getCommitIndex())));
|
||||
}
|
||||
});
|
||||
return ref.get();
|
||||
|
||||
@@ -102,15 +102,13 @@ class DetailsPanel extends JPanel implements ListSelectionListener {
|
||||
else {
|
||||
((CardLayout)getLayout()).show(this, STANDARD_LAYER);
|
||||
int row = rows[0];
|
||||
AbstractVcsLogTableModel tableModel = (AbstractVcsLogTableModel)myGraphTable.getModel();
|
||||
AbstractVcsLogTableModel<?,?> tableModel = (AbstractVcsLogTableModel)myGraphTable.getModel();
|
||||
Hash hash = tableModel.getHashAtRow(row);
|
||||
Object commit = tableModel.getCommit(row);
|
||||
if (hash == null || commit == null) {
|
||||
VcsFullCommitDetails commitData = myLogDataHolder.getCommitDetailsGetter().getCommitData(row, tableModel);
|
||||
if (commitData == null || hash == null) {
|
||||
showMessage("No commits selected");
|
||||
return;
|
||||
}
|
||||
|
||||
VcsFullCommitDetails commitData = myLogDataHolder.getCommitDetailsGetter().getCommitData(commit, tableModel.getAroundProvider());
|
||||
if (commitData instanceof LoadingDetails) {
|
||||
myLoadingPanel.startLoading();
|
||||
myDataPanel.setData(null);
|
||||
|
||||
+1
-8
@@ -7,7 +7,6 @@ import com.intellij.util.text.DateFormatUtil;
|
||||
import com.intellij.vcs.log.Hash;
|
||||
import com.intellij.vcs.log.VcsFullCommitDetails;
|
||||
import com.intellij.vcs.log.VcsShortCommitDetails;
|
||||
import com.intellij.vcs.log.data.AroundProvider;
|
||||
import com.intellij.vcs.log.graph.elements.Node;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -87,7 +86,7 @@ public abstract class AbstractVcsLogTableModel<CommitColumnClass, CommitId> exte
|
||||
public abstract List<Change> getSelectedChanges(@NotNull List<Integer> selectedRows);
|
||||
|
||||
@NotNull
|
||||
protected abstract VirtualFile getRoot(int rowIndex);
|
||||
public abstract VirtualFile getRoot(int rowIndex);
|
||||
|
||||
@NotNull
|
||||
protected abstract CommitColumnClass getCommitColumnCell(int index, @Nullable VcsShortCommitDetails details);
|
||||
@@ -95,9 +94,6 @@ public abstract class AbstractVcsLogTableModel<CommitColumnClass, CommitId> exte
|
||||
@NotNull
|
||||
protected abstract Class<CommitColumnClass> getCommitColumnClass();
|
||||
|
||||
@NotNull
|
||||
public abstract AroundProvider<CommitId> getAroundProvider();
|
||||
|
||||
/**
|
||||
* Returns the Hash of the commit displayed in the given row.
|
||||
* May be null if there is no commit in the row
|
||||
@@ -106,9 +102,6 @@ public abstract class AbstractVcsLogTableModel<CommitColumnClass, CommitId> exte
|
||||
@Nullable
|
||||
public abstract Hash getHashAtRow(int row);
|
||||
|
||||
@Nullable
|
||||
public abstract CommitId getCommit(int row);
|
||||
|
||||
@Override
|
||||
public Class<?> getColumnClass(int column) {
|
||||
switch (column) {
|
||||
|
||||
@@ -8,10 +8,11 @@ import com.intellij.vcs.log.Hash;
|
||||
import com.intellij.vcs.log.VcsFullCommitDetails;
|
||||
import com.intellij.vcs.log.VcsRef;
|
||||
import com.intellij.vcs.log.VcsShortCommitDetails;
|
||||
import com.intellij.vcs.log.data.*;
|
||||
import com.intellij.vcs.log.data.DataPack;
|
||||
import com.intellij.vcs.log.data.LoadingDetails;
|
||||
import com.intellij.vcs.log.data.VcsLogDataHolder;
|
||||
import com.intellij.vcs.log.graph.elements.Node;
|
||||
import com.intellij.vcs.log.graph.render.GraphCommitCell;
|
||||
import com.intellij.vcs.log.graph.render.PositionUtil;
|
||||
import com.intellij.vcs.log.printmodel.GraphPrintCell;
|
||||
import com.intellij.vcs.log.ui.VcsLogUI;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -31,13 +32,11 @@ public class GraphTableModel extends AbstractVcsLogTableModel<GraphCommitCell, N
|
||||
@NotNull private final DataPack myDataPack;
|
||||
@NotNull private final VcsLogDataHolder myDataHolder;
|
||||
@NotNull private final VcsLogUI myUi;
|
||||
@NotNull private final NodeAroundProvider myNodeAroundProvider;
|
||||
|
||||
public GraphTableModel(@NotNull VcsLogDataHolder dataHolder, @NotNull VcsLogUI ui) {
|
||||
myDataHolder = dataHolder;
|
||||
myUi = ui;
|
||||
myDataPack = dataHolder.getDataPack();
|
||||
myNodeAroundProvider = new NodeAroundProvider(myDataPack, dataHolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,15 +47,13 @@ public class GraphTableModel extends AbstractVcsLogTableModel<GraphCommitCell, N
|
||||
@Nullable
|
||||
@Override
|
||||
protected VcsShortCommitDetails getShortDetails(int rowIndex) {
|
||||
Node commitNode = myDataPack.getGraphModel().getGraph().getCommitNodeInRow(rowIndex);
|
||||
return commitNode == null ? null : myDataHolder.getMiniDetailsGetter().getCommitData(commitNode, myNodeAroundProvider);
|
||||
return myDataHolder.getMiniDetailsGetter().getCommitData(rowIndex, this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public VcsFullCommitDetails getFullCommitDetails(int row) {
|
||||
Node node = myDataPack.getGraphModel().getGraph().getCommitNodeInRow(row);
|
||||
return node == null ? null : myDataHolder.getCommitDetailsGetter().getCommitData(node, myNodeAroundProvider);
|
||||
return myDataHolder.getCommitDetailsGetter().getCommitData(row, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -68,9 +65,9 @@ public class GraphTableModel extends AbstractVcsLogTableModel<GraphCommitCell, N
|
||||
@Override
|
||||
public List<Change> getSelectedChanges(@NotNull List<Integer> selectedRows) {
|
||||
List<Change> changes = new ArrayList<Change>();
|
||||
for (Node node : nodes(selectedRows)) {
|
||||
VcsFullCommitDetails commitData = myDataHolder.getCommitDetailsGetter().getCommitData(node, myNodeAroundProvider);
|
||||
if (commitData instanceof LoadingDetails) {
|
||||
for (int row : selectedRows) {
|
||||
VcsFullCommitDetails commitData = myDataHolder.getCommitDetailsGetter().getCommitData(row, this);
|
||||
if (commitData == null || commitData instanceof LoadingDetails) {
|
||||
return null;
|
||||
}
|
||||
changes.addAll(commitData.getChanges());
|
||||
@@ -78,18 +75,6 @@ public class GraphTableModel extends AbstractVcsLogTableModel<GraphCommitCell, N
|
||||
return changes;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private List<Node> nodes(@NotNull List<Integer> selectedRows) {
|
||||
List<Node> result = new ArrayList<Node>();
|
||||
for (int rowIndex : selectedRows) {
|
||||
Node node = PositionUtil.getNode(getGraphPrintCellForRow(rowIndex));
|
||||
if (node != null) {
|
||||
result.add(node);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private GraphPrintCell getGraphPrintCellForRow(int row) {
|
||||
Object commitValue = getValueAt(row, AbstractVcsLogTableModel.COMMIT_COLUMN);
|
||||
@@ -102,7 +87,7 @@ public class GraphTableModel extends AbstractVcsLogTableModel<GraphCommitCell, N
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected VirtualFile getRoot(int rowIndex) {
|
||||
public VirtualFile getRoot(int rowIndex) {
|
||||
Node commitNode = myDataPack.getGraphModel().getGraph().getCommitNodeInRow(rowIndex);
|
||||
return commitNode != null ? commitNode.getBranch().getRepositoryRoot() : FAKE_ROOT;
|
||||
}
|
||||
@@ -131,20 +116,8 @@ public class GraphTableModel extends AbstractVcsLogTableModel<GraphCommitCell, N
|
||||
@Nullable
|
||||
@Override
|
||||
public Hash getHashAtRow(int row) {
|
||||
Node node = getCommit(row);
|
||||
Node node = myDataPack.getGraphModel().getGraph().getCommitNodeInRow(row);
|
||||
return node == null ? null : myDataHolder.getHash(node.getCommitIndex());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Node getCommit(int row) {
|
||||
return myDataPack.getGraphModel().getGraph().getCommitNodeInRow(row);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public AroundProvider<Node> getAroundProvider() {
|
||||
return myNodeAroundProvider;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,16 +2,12 @@ package com.intellij.vcs.log.ui.tables;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Attachment;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import com.intellij.vcs.log.Hash;
|
||||
import com.intellij.vcs.log.VcsFullCommitDetails;
|
||||
import com.intellij.vcs.log.VcsRef;
|
||||
import com.intellij.vcs.log.VcsShortCommitDetails;
|
||||
import com.intellij.vcs.log.data.AroundProvider;
|
||||
import com.intellij.vcs.log.data.LoadMoreStage;
|
||||
import com.intellij.vcs.log.data.RefsModel;
|
||||
import com.intellij.vcs.log.graph.render.CommitCell;
|
||||
@@ -19,7 +15,10 @@ import com.intellij.vcs.log.ui.VcsLogUI;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class NoGraphTableModel extends AbstractVcsLogTableModel<CommitCell, Hash> {
|
||||
@@ -29,7 +28,6 @@ public class NoGraphTableModel extends AbstractVcsLogTableModel<CommitCell, Hash
|
||||
@NotNull private final VcsLogUI myUi;
|
||||
@NotNull private final List<VcsFullCommitDetails> myCommits;
|
||||
@NotNull private final RefsModel myRefsModel;
|
||||
@NotNull private final AroundProvider<Hash> myAroundProvider;
|
||||
@NotNull private final LoadMoreStage myLoadMoreStage;
|
||||
@NotNull private final AtomicBoolean myLoadMoreWasRequested = new AtomicBoolean();
|
||||
|
||||
@@ -39,7 +37,6 @@ public class NoGraphTableModel extends AbstractVcsLogTableModel<CommitCell, Hash
|
||||
myCommits = commits;
|
||||
myRefsModel = refsModel;
|
||||
myLoadMoreStage = loadMoreStage;
|
||||
myAroundProvider = new HashAroundProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -84,7 +81,7 @@ public class NoGraphTableModel extends AbstractVcsLogTableModel<CommitCell, Hash
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected VirtualFile getRoot(int rowIndex) {
|
||||
public VirtualFile getRoot(int rowIndex) {
|
||||
VcsFullCommitDetails commit = myCommits.get(rowIndex);
|
||||
if (commit != null) {
|
||||
return commit.getRoot();
|
||||
@@ -118,51 +115,4 @@ public class NoGraphTableModel extends AbstractVcsLogTableModel<CommitCell, Hash
|
||||
public Hash getHashAtRow(int row) {
|
||||
return myCommits.get(row).getHash();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Hash getCommit(int row) {
|
||||
return getHashAtRow(row);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public AroundProvider<Hash> getAroundProvider() {
|
||||
return myAroundProvider;
|
||||
}
|
||||
|
||||
private class HashAroundProvider implements AroundProvider<Hash> {
|
||||
@NotNull
|
||||
@Override
|
||||
public MultiMap<VirtualFile, Hash> getCommitsAround(@NotNull Hash selectedHash, int above, int below) {
|
||||
int rowIndex = findRowIndex(selectedHash);
|
||||
if (rowIndex < 0) {
|
||||
LOG.error("Couldn't find the hash " + selectedHash + " among supplied commits",
|
||||
new Attachment("filtered_commits.txt", myCommits.toString()));
|
||||
return MultiMap.emptyInstance();
|
||||
}
|
||||
|
||||
MultiMap<VirtualFile, Hash> commits = MultiMap.create();
|
||||
for (int i = Math.max(0, rowIndex - above); i < rowIndex + below && i < myCommits.size(); i++) {
|
||||
VcsFullCommitDetails details = myCommits.get(i);
|
||||
commits.putValue(details.getRoot(), details.getHash());
|
||||
}
|
||||
return commits;
|
||||
}
|
||||
|
||||
private int findRowIndex(final Hash hash) {
|
||||
return ContainerUtil.indexOf(myCommits, new Condition<VcsFullCommitDetails>() {
|
||||
@Override
|
||||
public boolean value(VcsFullCommitDetails details) {
|
||||
return details.getHash().equals(hash);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Hash resolveId(@NotNull Hash hash) {
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -484,39 +484,11 @@ public class GitHistoryUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<? extends VcsShortCommitDetails> readAllMiniDetails(final Project project, final VirtualFile root) throws VcsException {
|
||||
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.LOG);
|
||||
GitLogParser parser = new GitLogParser(project, GitLogParser.NameStatus.NONE, HASH, PARENTS, AUTHOR_NAME,
|
||||
AUTHOR_EMAIL, AUTHOR_TIME, SUBJECT);
|
||||
h.setStdoutSuppressed(true);
|
||||
h.addParameters(parser.getPretty(), "--encoding=UTF-8");
|
||||
h.addParameters(LOG_ALL);
|
||||
h.addParameters("--full-history", "--sparse");
|
||||
h.endOptions();
|
||||
|
||||
String output = h.run();
|
||||
|
||||
List<GitLogRecord> records = parser.parse(output);
|
||||
|
||||
return ContainerUtil.mapNotNull(records, new Function<GitLogRecord, VcsShortCommitDetails>() {
|
||||
@Override
|
||||
public VcsShortCommitDetails fun(GitLogRecord record) {
|
||||
List<Hash> parents = new SmartList<Hash>();
|
||||
for (String parent : record.getParentsHashes()) {
|
||||
parents.add(HashImpl.build(parent));
|
||||
}
|
||||
|
||||
return vcsObjectsFactory(project).createShortDetails(HashImpl.build(record.getHash()), parents, record.getAuthorTimeStamp(), root,
|
||||
record.getSubject(), record.getAuthorName(), record.getAuthorEmail());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static List<? extends VcsShortCommitDetails> readMiniDetails(final Project project, final VirtualFile root, List<String> hashes) throws VcsException {
|
||||
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.LOG);
|
||||
GitLogParser parser = new GitLogParser(project, GitLogParser.NameStatus.NONE, HASH, PARENTS, AUTHOR_NAME,
|
||||
AUTHOR_EMAIL, COMMIT_TIME, SUBJECT);
|
||||
h.setStdoutSuppressed(true);
|
||||
h.setSilent(true);
|
||||
// git show can show either -p, or --name-status, or --name-only, but we need nothing, just details => using git log --no-walk
|
||||
h.addParameters("--no-walk");
|
||||
h.addParameters(parser.getPretty(), "--encoding=UTF-8");
|
||||
@@ -1032,7 +1004,7 @@ public class GitHistoryUtils {
|
||||
GitLogParser parser = new GitLogParser(project, GitLogParser.NameStatus.STATUS,
|
||||
HASH, HASH, COMMIT_TIME, AUTHOR_NAME, AUTHOR_TIME, AUTHOR_EMAIL, COMMITTER_NAME,
|
||||
COMMITTER_EMAIL, PARENTS, REF_NAMES, SUBJECT, BODY, RAW_BODY);
|
||||
h.setStdoutSuppressed(true);
|
||||
h.setSilent(true);
|
||||
h.addParameters("--name-status", "-M", parser.getPretty(), "--encoding=UTF-8");
|
||||
h.addParameters(new ArrayList<String>(commitsIds));
|
||||
|
||||
@@ -1048,20 +1020,9 @@ public class GitHistoryUtils {
|
||||
@NotNull
|
||||
public static List<GitCommit> commitsDetails(@NotNull Project project, @NotNull VirtualFile root,
|
||||
@NotNull final Collection<String> hashes) throws VcsException {
|
||||
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.SHOW);
|
||||
GitLogParser parser = new GitLogParser(project, GitLogParser.NameStatus.STATUS,
|
||||
HASH, HASH, COMMIT_TIME, AUTHOR_NAME, AUTHOR_TIME, AUTHOR_EMAIL, COMMITTER_NAME,
|
||||
COMMITTER_EMAIL, PARENTS, REF_NAMES, SUBJECT, BODY, RAW_BODY);
|
||||
h.setStdoutSuppressed(true);
|
||||
h.addParameters("--name-status", "-M", parser.getPretty(), "--encoding=UTF-8");
|
||||
h.addParameters(new ArrayList<String>(hashes));
|
||||
|
||||
String output = h.run();
|
||||
final List<GitCommit> rc = new ArrayList<GitCommit>();
|
||||
for (GitLogRecord record : parser.parse(output)) {
|
||||
rc.add(createCommit(project, root, record));
|
||||
}
|
||||
return rc;
|
||||
List<String> params = new ArrayList<String>(hashes);
|
||||
params.add(0, "--no-walk=unsorted");
|
||||
return getAllDetails(project, root, params);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -1071,7 +1032,7 @@ public class GitHistoryUtils {
|
||||
GitLogParser parser = new GitLogParser(project, GitLogParser.NameStatus.STATUS,
|
||||
HASH, HASH, COMMIT_TIME, AUTHOR_NAME, AUTHOR_TIME, AUTHOR_EMAIL, COMMITTER_NAME,
|
||||
COMMITTER_EMAIL, PARENTS, REF_NAMES, SUBJECT, BODY, RAW_BODY);
|
||||
h.setStdoutSuppressed(true);
|
||||
h.setSilent(true);
|
||||
h.addParameters("--name-status", "-M", parser.getPretty(), "--encoding=UTF-8");
|
||||
h.addParameters(parameters);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user