From 2004462f86f397b7bed95bec4927b1fe87472377 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Fri, 3 Jan 2014 17:09:52 +0400 Subject: [PATCH 1/4] [log] simplify loading details around selected commit No need to implement some AroundProvider: we can take data right from the table model, by row index. DataGetter#getCommitData has to be Nullable now, because there can be "empty" rows holding no commits. VcsLogFilterer can't use new getCommitData, because there is no table model to supply: it actually gets created from the filterer. However, we expect details to be in the cache, so there is no need to load around anyway. --- .../intellij/vcs/log/data/AroundProvider.java | 51 ------------- .../com/intellij/vcs/log/data/DataGetter.java | 31 ++++++-- .../vcs/log/data/NodeAroundProvider.java | 73 ------------------- .../intellij/vcs/log/data/VcsLogFilterer.java | 13 ++-- .../vcs/log/ui/frame/DetailsPanel.java | 8 +- .../ui/tables/AbstractVcsLogTableModel.java | 9 +-- .../vcs/log/ui/tables/GraphTableModel.java | 47 +++--------- .../vcs/log/ui/tables/NoGraphTableModel.java | 60 ++------------- 8 files changed, 50 insertions(+), 242 deletions(-) delete mode 100644 platform/vcs-log/impl/src/com/intellij/vcs/log/data/AroundProvider.java delete mode 100644 platform/vcs-log/impl/src/com/intellij/vcs/log/data/NodeAroundProvider.java diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/AroundProvider.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/AroundProvider.java deleted file mode 100644 index b7baab383113..000000000000 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/AroundProvider.java +++ /dev/null @@ -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.
- * This is needed to be able to smartly get commit details from the VCS in a batch. - * - * @param Commit identifier, which can be, for example, a {@link Hash} or an {@link Integer} or a {@link Node}. - */ -public interface AroundProvider { - - /** - * Returns commits which are located around the given commit in the log table.
- * The returned map must include the commit which was requested originally.
- * 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 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); - -} diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataGetter.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataGetter.java index dd35645dfab1..074dc2ebaa8b 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataGetter.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataGetter.java @@ -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 implements Dis myLoadingFinishedListeners.clear(); } - @NotNull - public T getCommitData(@NotNull CommitId id, @NotNull AroundProvider aroundProvider) { + @Nullable + public T getCommitData(int row, @NotNull AbstractVcsLogTableModel 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 implements Dis return (T)myDataHolder.getTopCommitDetails(hash); } - private void runLoadAroundCommitData(@NotNull CommitId id, @NotNull AroundProvider aroundProvider) { + private void runLoadAroundCommitData(int row, @NotNull AbstractVcsLogTableModel tableModel) { long taskNumber = myCurrentTaskIndex++; - MultiMap commits = aroundProvider.getCommitsAround(id, UP_PRELOAD_COUNT, DOWN_PRELOAD_COUNT); + MultiMap commits = getCommitsAround(row, tableModel, UP_PRELOAD_COUNT, DOWN_PRELOAD_COUNT); for (Map.Entry> hashesByRoots : commits.entrySet()) { VirtualFile root = hashesByRoots.getKey(); Collection hashes = hashesByRoots.getValue(); @@ -132,6 +136,21 @@ public abstract class DataGetter implements Dis myLoader.queue(task); } + @NotNull + private static MultiMap getCommitsAround(int selectedRow, + @NotNull AbstractVcsLogTableModel model, + int above, int below) { + MultiMap 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 commits) throws VcsException { for (Map.Entry> entry : commits.entrySet()) { List hashStrings = ContainerUtil.map(entry.getValue(), new Function() { diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/NodeAroundProvider.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/NodeAroundProvider.java deleted file mode 100644 index 0eaf2b8ba341..000000000000 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/NodeAroundProvider.java +++ /dev/null @@ -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 { - - @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 getCommitsAround(@NotNull Node node, int above, int below) { - MultiMap 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; - } - -} diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogFilterer.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogFilterer.java index fc1eadeef914..2c3011135dd5 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogFilterer.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogFilterer.java @@ -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 filteredCommits = filterByDetails(dataPack, graphModel, detailsFilters); + List filteredCommits = filterByDetails(graphModel, detailsFilters); model = new NoGraphTableModel(myUI, filteredCommits, dataPack.getRefsModel(), LoadMoreStage.INITIAL); } else { @@ -147,18 +147,17 @@ public class VcsLogFilterer { }); } - private List filterByDetails(DataPack dataPack, final GraphModel graphModel, - final List detailsFilters) { + @NotNull + private List filterByDetails(@NotNull GraphModel graphModel, @NotNull List detailsFilters) { List 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 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(); diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java index bf34384aeee9..76e3378af6c9 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java @@ -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); diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/AbstractVcsLogTableModel.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/AbstractVcsLogTableModel.java index 2b573806d532..7ff8c110baf3 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/AbstractVcsLogTableModel.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/AbstractVcsLogTableModel.java @@ -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 exte public abstract List getSelectedChanges(@NotNull List 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 exte @NotNull protected abstract Class getCommitColumnClass(); - @NotNull - public abstract AroundProvider 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 exte @Nullable public abstract Hash getHashAtRow(int row); - @Nullable - public abstract CommitId getCommit(int row); - @Override public Class getColumnClass(int column) { switch (column) { diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/GraphTableModel.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/GraphTableModel.java index bd0c8c2beec2..21e6cd4ecac7 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/GraphTableModel.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/GraphTableModel.java @@ -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 getSelectedChanges(@NotNull List selectedRows) { List changes = new ArrayList(); - 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 nodes(@NotNull List selectedRows) { - List result = new ArrayList(); - 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 getAroundProvider() { - return myNodeAroundProvider; - } - } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/NoGraphTableModel.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/NoGraphTableModel.java index 15f6ed0a35d3..1cdd138a6fc7 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/NoGraphTableModel.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/NoGraphTableModel.java @@ -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 { @@ -29,7 +28,6 @@ public class NoGraphTableModel extends AbstractVcsLogTableModel myCommits; @NotNull private final RefsModel myRefsModel; - @NotNull private final AroundProvider myAroundProvider; @NotNull private final LoadMoreStage myLoadMoreStage; @NotNull private final AtomicBoolean myLoadMoreWasRequested = new AtomicBoolean(); @@ -39,7 +37,6 @@ public class NoGraphTableModel extends AbstractVcsLogTableModel getAroundProvider() { - return myAroundProvider; - } - - private class HashAroundProvider implements AroundProvider { - @NotNull - @Override - public MultiMap 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 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() { - @Override - public boolean value(VcsFullCommitDetails details) { - return details.getHash().equals(hash); - } - }); - } - - @NotNull - @Override - public Hash resolveId(@NotNull Hash hash) { - return hash; - } - } } From b79e75947e699fb70c26b5236b27ecabf0ccc4d9 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Fri, 3 Jan 2014 17:19:40 +0400 Subject: [PATCH 2/4] [git] write less garbage to the log --- .../git4idea/src/git4idea/history/GitHistoryUtils.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java b/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java index c1353e769313..b5daf0a58e36 100644 --- a/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java +++ b/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java @@ -516,7 +516,7 @@ public class GitHistoryUtils { 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 +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(new ArrayList(commitsIds)); @@ -1052,7 +1052,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(hashes)); @@ -1071,7 +1071,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); From 35d0bc259b54895fc15f69f2ead0d41511ed0a2e Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Fri, 3 Jan 2014 17:20:14 +0400 Subject: [PATCH 3/4] [git] remove unused --- .../src/git4idea/history/GitHistoryUtils.java | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java b/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java index b5daf0a58e36..30841944391c 100644 --- a/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java +++ b/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java @@ -484,34 +484,6 @@ public class GitHistoryUtils { return null; } - public static List 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 records = parser.parse(output); - - return ContainerUtil.mapNotNull(records, new Function() { - @Override - public VcsShortCommitDetails fun(GitLogRecord record) { - List parents = new SmartList(); - 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 readMiniDetails(final Project project, final VirtualFile root, List hashes) throws VcsException { GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.LOG); GitLogParser parser = new GitLogParser(project, GitLogParser.NameStatus.NONE, HASH, PARENTS, AUTHOR_NAME, From e422a27a618eac58f4f359a742d8f5b43f39e2d6 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Fri, 3 Jan 2014 17:34:09 +0400 Subject: [PATCH 4/4] [git] DRY 'git log --no-walk ' behaves the same as 'git show ' because --no-walk tells git "Only show the given commits, but do not traverse their ancestors". 'unsorted' tells Git to return commit details in the same order as hashes passed to the command. Among current usages of the method, we don't care about the order, but seems correct for possible future methods relying on this. --- .../src/git4idea/history/GitHistoryUtils.java | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java b/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java index 30841944391c..5a94334fee3a 100644 --- a/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java +++ b/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java @@ -1020,20 +1020,9 @@ public class GitHistoryUtils { @NotNull public static List commitsDetails(@NotNull Project project, @NotNull VirtualFile root, @NotNull final Collection 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.setSilent(true); - h.addParameters("--name-status", "-M", parser.getPretty(), "--encoding=UTF-8"); - h.addParameters(new ArrayList(hashes)); - - String output = h.run(); - final List rc = new ArrayList(); - for (GitLogRecord record : parser.parse(output)) { - rc.add(createCommit(project, root, record)); - } - return rc; + List params = new ArrayList(hashes); + params.add(0, "--no-walk=unsorted"); + return getAllDetails(project, root, params); } @NotNull