[log] Refactor VcsCommitDetails

* Rename to VcsShortCommitDetails & VcsFullCommitDetails.
* Separate interface from implementation.
* Don't extend CommitParents: details are not commits. Just hold the
  instance of the CommitParents in Vcs*CommitDetails.
* Introduce VcsLogObjectsFactory to provide create*() methods to
  create standard instances of the Hash and Details objects.
This commit is contained in:
Kirill Likhodedov
2013-09-27 16:12:15 +04:00
parent 2c49d81d7f
commit 527f077278
25 changed files with 284 additions and 141 deletions
@@ -1,34 +0,0 @@
package com.intellij.vcs.log;
import org.jetbrains.annotations.NotNull;
import java.util.List;
/**
* Provides so called "mini-details" of a commit, that are needed to display information in the log table.
*
* @author Kirill Likhodedov
* @see VcsCommitDetails
*/
public class VcsCommitMiniDetails extends TimeCommitParents {
@NotNull private final String mySubject;
@NotNull private final String myAuthorName;
public VcsCommitMiniDetails(@NotNull Hash hash, @NotNull List<Hash> parents, long timeStamp,
@NotNull String subject, @NotNull String authorName) {
super(hash, parents, timeStamp);
mySubject = subject;
myAuthorName = authorName;
}
@NotNull
public final String getSubject() {
return mySubject;
}
@NotNull
public final String getAuthorName() {
return myAuthorName;
}
}
@@ -0,0 +1,39 @@
package com.intellij.vcs.log;
import com.intellij.openapi.vcs.changes.Change;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.List;
/**
* <p>Full details of a commit: all metadata (commit message, author, committer, etc.) and the changes.</p>
* <p/>
* <p>These details will be shown in dedicated panels displayed near the log.</p>
* <p/>
* <p>An instance of this object can be obtained via
* {@link VcsLogObjectsFactory#createFullDetails(Hash, List, long, String, String, String, String, String, String, long, List)
* VcsLogObjectsFactory#createFullDetails}</p>
*
* @author Kirill Likhodedov
*/
public interface VcsFullCommitDetails extends VcsShortCommitDetails {
@NotNull
String getFullMessage();
@NotNull
Collection<Change> getChanges();
@NotNull
String getAuthorEmail();
@NotNull
String getCommitterName();
@NotNull
String getCommitterEmail();
long getCommitTime();
}
@@ -0,0 +1,27 @@
package com.intellij.vcs.log;
import com.intellij.openapi.vcs.changes.Change;
import org.jetbrains.annotations.NotNull;
import java.util.List;
/**
* Use this factory to create correct instances of such commonly used vcs-log-api objects as {@link Hash} or {@link VcsShortCommitDetails}.
*
* @author Kirill Likhodedov
*/
public interface VcsLogObjectsFactory {
@NotNull
Hash createHash(@NotNull String stringHash);
@NotNull
VcsShortCommitDetails createShortDetails(@NotNull Hash hash, @NotNull List<Hash> parents, long timeStamp,
@NotNull String subject, @NotNull String authorName);
@NotNull
VcsFullCommitDetails createFullDetails(@NotNull Hash hash, @NotNull List<Hash> parents, long authorTime, @NotNull String subject,
@NotNull String authorName, @NotNull String authorEmail, @NotNull String message,
@NotNull String committerName,
@NotNull String committerEmail, long commitTime, @NotNull List<Change> changes);
}
@@ -22,7 +22,7 @@ public interface VcsLogProvider {
* Reads {@link #COMMIT_BLOCK_SIZE the first part} of the log.
*/
@NotNull
List<? extends VcsCommitDetails> readFirstBlock(@NotNull VirtualFile root, boolean ordered) throws VcsException;
List<? extends VcsFullCommitDetails> readFirstBlock(@NotNull VirtualFile root, boolean ordered) throws VcsException;
/**
* Reads the whole history, but only hashes & parents.
@@ -34,13 +34,13 @@ public interface VcsLogProvider {
* Reads those details of the given commits, which are necessary to be shown in the log table.
*/
@NotNull
List<? extends VcsCommitMiniDetails> readMiniDetails(@NotNull VirtualFile root, @NotNull List<String> hashes) throws VcsException;
List<? extends VcsShortCommitDetails> readShortDetails(@NotNull VirtualFile root, @NotNull List<String> hashes) throws VcsException;
/**
* Read full details of the given commits from the VCS.
*/
@NotNull
List<? extends VcsCommitDetails> readDetails(@NotNull VirtualFile root, @NotNull List<String> hashes) throws VcsException;
List<? extends VcsFullCommitDetails> readFullDetails(@NotNull VirtualFile root, @NotNull List<String> hashes) throws VcsException;
/**
* Read all references (branches, tags, etc.) for the given roots.
@@ -0,0 +1,34 @@
package com.intellij.vcs.log;
import org.jetbrains.annotations.NotNull;
import java.util.List;
/**
* <p>Returns the basic level of commit meta-data: author, time, subject.</p>
*
* <p>These details will be displayed in the log table.</p>
*
* <p>An instance of this object can be obtained via
* {@link VcsLogObjectsFactory#createShortDetails(Hash, List, long, String, String) VcsLogObjectsFactory#createShortDetails}</p>
*
* @see VcsFullCommitDetails
* @author Kirill Likhodedov
*/
public interface VcsShortCommitDetails {
@NotNull
Hash getHash();
@NotNull
List<Hash> getParents();
long getAuthorTime();
@NotNull
String getSubject();
@NotNull
String getAuthorName();
}
@@ -1,6 +1,6 @@
package com.intellij.vcs.log.parser;
import com.intellij.vcs.log.VcsCommitMiniDetails;
import com.intellij.vcs.log.VcsShortCommitDetails;
import junit.framework.Assert;
import org.jetbrains.annotations.NotNull;
import org.junit.Test;
@@ -12,7 +12,7 @@ import static junit.framework.Assert.assertEquals;
*/
public class CommitDataParserTest {
private static String toStr(@NotNull VcsCommitMiniDetails commitData) {
private static String toStr(@NotNull VcsShortCommitDetails commitData) {
StringBuilder s = new StringBuilder();
s.append(commitData.getHash()).append("|-");
s.append(commitData.getAuthorName()).append("|-");
@@ -22,7 +22,7 @@ public class CommitDataParserTest {
}
private void runTest(@NotNull String inputStr) {
VcsCommitMiniDetails commitData = CommitParser.parseCommitData(inputStr);
VcsShortCommitDetails commitData = CommitParser.parseCommitData(inputStr);
assertEquals(inputStr, toStr(commitData));
}
@@ -58,7 +58,7 @@ public class CommitDataParserTest {
@Test
public void emptyTimestamp() {
VcsCommitMiniDetails commitData = CommitParser.parseCommitData("af56|-author |-|-message");
VcsShortCommitDetails commitData = CommitParser.parseCommitData("af56|-author |-|-message");
Assert.assertEquals("author ", commitData.getAuthorName());
Assert.assertEquals(0, commitData.getAuthorTime());
Assert.assertEquals("message", commitData.getSubject());
@@ -1,5 +1,6 @@
package com.intellij.vcs.log.parser;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.vcs.log.*;
@@ -33,14 +34,14 @@ public class CommitParser {
public static CommitParents parseCommitParents(@NotNull String line) {
int separatorIndex = nextSeparatorIndex(line, 0);
String commitHashStr = line.substring(0, separatorIndex);
Hash commitHash = new SimpleHash(commitHashStr);
Hash commitHash = createHash(commitHashStr);
String parentHashStr = line.substring(separatorIndex + 2, line.length());
String[] parentsHashes = parentHashStr.split("\\s");
List<Hash> hashes = new ArrayList<Hash>(parentsHashes.length);
for (String aParentsStr : parentsHashes) {
if (aParentsStr.length() > 0) {
hashes.add(new SimpleHash(aParentsStr));
hashes.add(createHash(aParentsStr));
}
}
return new SimpleCommitParents(commitHash, hashes);
@@ -76,7 +77,7 @@ public class CommitParser {
* hash|-author name|-123124|-commit message
*/
@NotNull
public static VcsCommitMiniDetails parseCommitData(@NotNull String line) {
public static VcsShortCommitDetails parseCommitData(@NotNull String line) {
int prevIndex = 0;
int nextIndex = nextSeparatorIndex(line, 0);
final String hashStr = line.substring(0, nextIndex);
@@ -104,7 +105,8 @@ public class CommitParser {
final String commitMessage = line.substring(nextIndex + 2);
return new VcsCommitMiniDetails(new SimpleHash(hashStr), Collections.<Hash>emptyList(), timestamp, commitMessage, authorName);
VcsLogObjectsFactory factory = ServiceManager.getService(VcsLogObjectsFactory.class);
return factory.createShortDetails(factory.createHash(hashStr), Collections.<Hash>emptyList(), timestamp, commitMessage, authorName);
}
@@ -117,4 +119,10 @@ public class CommitParser {
}
});
}
@NotNull
private static Hash createHash(@NotNull String s) {
return ServiceManager.getService(VcsLogObjectsFactory.class).createHash(s);
}
}
@@ -1,43 +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.parser;
import com.intellij.vcs.log.Hash;
import org.jetbrains.annotations.NotNull;
/**
* @author Kirill Likhodedov
*/
class SimpleHash implements Hash {
private final String myHash;
public SimpleHash(String hash) {
myHash = hash;
}
@NotNull
@Override
public String asString() {
return myHash;
}
@NotNull
@Override
public String toShortString() {
return myHash.substring(0, 7);
}
}
@@ -8,6 +8,7 @@
<extensions defaultExtensionNs="com.intellij">
<applicationService serviceInterface="com.intellij.vcs.log.VcsLogObjectsFactory" serviceImplementation="com.intellij.vcs.log.VcsLogObjectsFactoryImpl" />
<projectService serviceInterface="com.intellij.vcs.log.VcsLogSettings" serviceImplementation="com.intellij.vcs.log.impl.VcsLogSettingsImpl"/>
</extensions>
</idea-plugin>
@@ -2,7 +2,7 @@ package com.intellij.vcs.log.data;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.vcs.log.VcsCommitDetails;
import com.intellij.vcs.log.VcsFullCommitDetails;
import com.intellij.vcs.log.VcsLogProvider;
import org.jetbrains.annotations.NotNull;
@@ -10,21 +10,21 @@ import java.util.List;
import java.util.Map;
/**
* The CommitDetailsGetter is responsible for getting {@link VcsCommitDetails complete commit details} from the cache or from the VCS.
* The CommitDetailsGetter is responsible for getting {@link VcsFullCommitDetails complete commit details} from the cache or from the VCS.
*
* @author Kirill Likhodedov
*/
public class CommitDetailsGetter extends DataGetter<VcsCommitDetails> {
public class CommitDetailsGetter extends DataGetter<VcsFullCommitDetails> {
CommitDetailsGetter(VcsLogDataHolder dataHolder, @NotNull Map<VirtualFile, VcsLogProvider> logProviders) {
super(dataHolder, logProviders, new VcsCommitCache<VcsCommitDetails>());
super(dataHolder, logProviders, new VcsCommitCache<VcsFullCommitDetails>());
}
@NotNull
@Override
protected List<? extends VcsCommitDetails> readDetails(@NotNull VcsLogProvider logProvider, @NotNull VirtualFile root,
protected List<? extends VcsFullCommitDetails> readDetails(@NotNull VcsLogProvider logProvider, @NotNull VirtualFile root,
@NotNull List<String> hashes) throws VcsException {
return logProvider.readDetails(root, hashes);
return logProvider.readFullDetails(root, hashes);
}
}
@@ -8,9 +8,9 @@ import com.intellij.util.Consumer;
import com.intellij.util.concurrency.QueueProcessor;
import com.intellij.util.containers.MultiMap;
import com.intellij.util.ui.UIUtil;
import com.intellij.vcs.log.CommitParents;
import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.VcsLogProvider;
import com.intellij.vcs.log.VcsShortCommitDetails;
import com.intellij.vcs.log.graph.Graph;
import com.intellij.vcs.log.graph.elements.Node;
import com.intellij.vcs.log.graph.elements.NodeRow;
@@ -34,7 +34,7 @@ import java.util.Map;
*
* @author Kirill Likhodedov
*/
public abstract class DataGetter<T extends CommitParents> implements Disposable {
public abstract class DataGetter<T extends VcsShortCommitDetails> implements Disposable {
private static final int UP_PRELOAD_COUNT = 20;
private static final int DOWN_PRELOAD_COUNT = 40;
@@ -2,18 +2,18 @@ package com.intellij.vcs.log.data;
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.VcsCommitDetails;
import com.intellij.vcs.log.impl.VcsFullCommitDetailsImpl;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
/**
* Fake {@link VcsCommitDetails} implementation that is used to indicate that details are not ready for the moment,
* Fake {@link VcsFullCommitDetailsImpl} implementation that is used to indicate that details are not ready for the moment,
* they are being retrieved from the VCS.
*
* @author Kirill Likhodedov
*/
public class LoadingDetails extends VcsCommitDetails {
public class LoadingDetails extends VcsFullCommitDetailsImpl {
public LoadingDetails(@NotNull Hash hash) {
super(hash, Collections.<Hash>emptyList(), -1, "Loading...", "", "", "", "", "", -1, Collections.<Change>emptyList());
@@ -2,8 +2,8 @@ package com.intellij.vcs.log.data;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.vcs.log.VcsCommitMiniDetails;
import com.intellij.vcs.log.VcsLogProvider;
import com.intellij.vcs.log.VcsShortCommitDetails;
import org.jetbrains.annotations.NotNull;
import java.util.List;
@@ -12,17 +12,17 @@ import java.util.Map;
/**
* @author Kirill Likhodedov
*/
public class MiniDetailsGetter extends DataGetter<VcsCommitMiniDetails> {
public class MiniDetailsGetter extends DataGetter<VcsShortCommitDetails> {
MiniDetailsGetter(@NotNull VcsLogDataHolder dataHolder, @NotNull Map<VirtualFile, VcsLogProvider> logProviders) {
super(dataHolder, logProviders, new VcsCommitCache<VcsCommitMiniDetails>());
super(dataHolder, logProviders, new VcsCommitCache<VcsShortCommitDetails>());
}
@NotNull
@Override
protected List<? extends VcsCommitMiniDetails> readDetails(@NotNull VcsLogProvider logProvider, @NotNull VirtualFile root,
protected List<? extends VcsShortCommitDetails> readDetails(@NotNull VcsLogProvider logProvider, @NotNull VirtualFile root,
@NotNull List<String> hashes) throws VcsException {
return logProvider.readMiniDetails(root, hashes);
return logProvider.readShortDetails(root, hashes);
}
}
@@ -16,8 +16,8 @@
package com.intellij.vcs.log.data;
import com.intellij.util.containers.SLRUMap;
import com.intellij.vcs.log.CommitParents;
import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.VcsShortCommitDetails;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -32,7 +32,7 @@ import java.awt.*;
*
* @author Kirill Likhodedov
*/
class VcsCommitCache<T extends CommitParents> {
class VcsCommitCache<T extends VcsShortCommitDetails> {
private final SLRUMap<Hash, T> myCache = new SLRUMap<Hash, T>(5000, 5000);
@@ -24,6 +24,7 @@ import com.intellij.openapi.util.Pair;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.Consumer;
import com.intellij.util.Function;
import com.intellij.util.ThrowableConsumer;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.HashSet;
@@ -177,7 +178,7 @@ public class VcsLogDataHolder implements Disposable {
/**
* Loads the top part of the log and rebuilds the graph & log table.
*
* @param onSuccess this task is called {@link UIUtil.invokeAndWaitIfNeeded(Runnable) on the EDT} after loading and graph
* @param onSuccess this task is called {@link UIUtil#invokeAndWaitIfNeeded(Runnable) on the EDT} after loading and graph
* building completes.
* @param invalidateWholeLog if the whole log data should be invalidated and will be retrieved in onSuccess.
*/
@@ -196,22 +197,29 @@ public class VcsLogDataHolder implements Disposable {
for (Map.Entry<VirtualFile, VcsLogProvider> entry : myLogProviders.entrySet()) {
VirtualFile root = entry.getKey();
VcsLogProvider logProvider = entry.getValue();
List<? extends VcsCommitDetails> firstBlock = logProvider.readFirstBlock(root, ordered);
List<? extends VcsFullCommitDetails> firstBlockDetails = logProvider.readFirstBlock(root, ordered);
Collection<VcsRef> newRefs = logProvider.readAllRefs(root);
myDetailsGetter.saveInCache(firstBlock);
myMiniDetailsGetter.saveInCache(firstBlock);
myDetailsGetter.saveInCache(firstBlockDetails);
myMiniDetailsGetter.saveInCache(firstBlockDetails);
List<TimeCommitParents> firstBlockCommits = ContainerUtil.map(firstBlockDetails, new Function<VcsFullCommitDetails, TimeCommitParents>() {
@Override
public TimeCommitParents fun(VcsFullCommitDetails details) {
return new TimeCommitParents(details.getHash(), details.getParents(), details.getAuthorTime());
}
});
List<TimeCommitParents> refreshedLog;
int newCommitsCount;
if (ordered) {
// the whole log is not loaded before the first refresh
refreshedLog = new ArrayList<TimeCommitParents>(firstBlock);
refreshedLog = new ArrayList<TimeCommitParents>(firstBlockCommits);
newCommitsCount = 0;
}
else {
Pair<List<TimeCommitParents>, Integer> joinResult = myLogJoiner.addCommits(myLogData.getLog(root), myLogData.getRefs(root),
firstBlock, newRefs);
firstBlockCommits, newRefs);
refreshedLog = joinResult.getFirst();
newCommitsCount = joinResult.getSecond();
}
@@ -225,7 +233,7 @@ public class VcsLogDataHolder implements Disposable {
commitsToShow = myDataPack.getGraphModel().getGraph().getNodeRows().size() + newCommitsCount;
}
else {
commitsToShow = firstBlock.size();
commitsToShow = firstBlockDetails.size();
}
logsToBuild.put(root, refreshedLog.subList(0, Math.min(commitsToShow, refreshedLog.size())));
}
@@ -1,17 +1,17 @@
package com.intellij.vcs.log;
package com.intellij.vcs.log.impl;
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.VcsFullCommitDetails;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.List;
/**
* Full details of a commit: all metadata (commit message, author, committer, etc.) and the changes.
*
* @author Kirill Likhodedov
*/
public class VcsCommitDetails extends VcsCommitMiniDetails {
public class VcsFullCommitDetailsImpl extends VcsShortCommitDetailsImpl implements VcsFullCommitDetails {
@NotNull private final String myFullMessage;
@@ -22,9 +22,10 @@ public class VcsCommitDetails extends VcsCommitMiniDetails {
@NotNull private final Collection<Change> myChanges;
public VcsCommitDetails(@NotNull Hash hash, @NotNull List<Hash> parents, long authorTime, @NotNull String subject,
@NotNull String authorName, @NotNull String authorEmail, @NotNull String message, @NotNull String committerName,
@NotNull String committerEmail, long commitTime, @NotNull List<Change> changes) {
public VcsFullCommitDetailsImpl(@NotNull Hash hash, @NotNull List<Hash> parents, long authorTime, @NotNull String subject,
@NotNull String authorName, @NotNull String authorEmail, @NotNull String message,
@NotNull String committerName,
@NotNull String committerEmail, long commitTime, @NotNull List<Change> changes) {
super(hash, parents, authorTime, subject, authorName);
myAuthorEmail = authorEmail;
myCommitterName = committerName;
@@ -34,31 +35,37 @@ public class VcsCommitDetails extends VcsCommitMiniDetails {
myChanges = changes;
}
@Override
@NotNull
public final String getFullMessage() {
return myFullMessage;
}
@Override
@NotNull
public final Collection<Change> getChanges() {
return myChanges;
}
@Override
@NotNull
public String getAuthorEmail() {
return myAuthorEmail;
}
@Override
@NotNull
public String getCommitterName() {
return myCommitterName;
}
@Override
@NotNull
public String getCommitterEmail() {
return myCommitterEmail;
}
@Override
public long getCommitTime() {
return myCommitTime;
}
@@ -0,0 +1,39 @@
package com.intellij.vcs.log.impl;
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.VcsFullCommitDetails;
import com.intellij.vcs.log.VcsLogObjectsFactory;
import com.intellij.vcs.log.VcsShortCommitDetails;
import org.jetbrains.annotations.NotNull;
import java.util.List;
/**
* @author Kirill Likhodedov
*/
public class VcsLogObjectsFactoryImpl implements VcsLogObjectsFactory {
@NotNull
@Override
public Hash createHash(@NotNull String stringHash) {
return HashImpl.build(stringHash);
}
@NotNull
@Override
public VcsShortCommitDetails createShortDetails(@NotNull Hash hash, @NotNull List<Hash> parents, long timeStamp,
@NotNull String subject, @NotNull String authorName) {
return new VcsShortCommitDetailsImpl(hash, parents, timeStamp, subject, authorName);
}
@NotNull
@Override
public VcsFullCommitDetails createFullDetails(@NotNull Hash hash, @NotNull List<Hash> parents, long authorTime, @NotNull String subject,
@NotNull String authorName, @NotNull String authorEmail, @NotNull String message,
@NotNull String committerName,
@NotNull String committerEmail, long commitTime, @NotNull List<Change> changes) {
return new VcsFullCommitDetailsImpl(hash, parents, authorTime, subject, authorName, authorEmail, message, committerName, committerEmail,
commitTime, changes);
}
}
@@ -0,0 +1,55 @@
package com.intellij.vcs.log.impl;
import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.TimeCommitParents;
import com.intellij.vcs.log.VcsShortCommitDetails;
import org.jetbrains.annotations.NotNull;
import java.util.List;
/**
* @author Kirill Likhodedov
*/
public class VcsShortCommitDetailsImpl implements VcsShortCommitDetails {
@NotNull private final TimeCommitParents myTimeCommitParents;
@NotNull private final String mySubject;
@NotNull private final String myAuthorName;
public VcsShortCommitDetailsImpl(@NotNull Hash hash, @NotNull List<Hash> parents, long timeStamp,
@NotNull String subject, @NotNull String authorName) {
myTimeCommitParents = new TimeCommitParents(hash, parents, timeStamp);
mySubject = subject;
myAuthorName = authorName;
}
@NotNull
@Override
public Hash getHash() {
return myTimeCommitParents.getHash();
}
@NotNull
@Override
public List<Hash> getParents() {
return myTimeCommitParents.getParents();
}
@Override
public long getAuthorTime() {
return myTimeCommitParents.getAuthorTime();
}
@Override
@NotNull
public final String getSubject() {
return mySubject;
}
@Override
@NotNull
public final String getAuthorName() {
return myAuthorName;
}
}
@@ -14,7 +14,7 @@ import com.intellij.openapi.vcs.changes.ui.ChangesBrowser;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.components.JBLoadingPanel;
import com.intellij.util.ArrayUtil;
import com.intellij.vcs.log.VcsCommitDetails;
import com.intellij.vcs.log.VcsFullCommitDetails;
import com.intellij.vcs.log.data.LoadingDetails;
import com.intellij.vcs.log.data.VcsLogDataHolder;
import com.intellij.vcs.log.graph.elements.Node;
@@ -124,7 +124,7 @@ public class ActiveSurface extends JPanel implements TypeSafeDataProvider {
public List<Change> getSelectedChanges() {
List<Change> changes = new ArrayList<Change>();
for (Node node : myGraphTable.getSelectedNodes()) {
VcsCommitDetails commitData = myLogDataHolder.getCommitDetailsGetter().getCommitData(node);
VcsFullCommitDetails commitData = myLogDataHolder.getCommitDetailsGetter().getCommitData(node);
if (commitData instanceof LoadingDetails) {
return null;
}
@@ -11,8 +11,8 @@ import com.intellij.ui.components.labels.LinkListener;
import com.intellij.util.ui.GridBag;
import com.intellij.util.ui.UIUtil;
import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.VcsFullCommitDetails;
import com.intellij.vcs.log.VcsRef;
import com.intellij.vcs.log.VcsCommitDetails;
import com.intellij.vcs.log.data.LoadingDetails;
import com.intellij.vcs.log.data.VcsLogDataHolder;
import com.intellij.vcs.log.graph.elements.Node;
@@ -92,7 +92,7 @@ class DetailsPanel extends JPanel implements ListSelectionListener {
return;
}
Hash hash = node.getCommitHash();
VcsCommitDetails commitData = myLogDataHolder.getCommitDetailsGetter().getCommitData(node);
VcsFullCommitDetails commitData = myLogDataHolder.getCommitDetailsGetter().getCommitData(node);
if (commitData instanceof LoadingDetails) {
myLoadingPanel.startLoading();
myDataPanel.setData(null);
@@ -148,7 +148,7 @@ class DetailsPanel extends JPanel implements ListSelectionListener {
setOpaque(false);
}
void setData(@Nullable VcsCommitDetails commit) {
void setData(@Nullable VcsFullCommitDetails commit) {
if (commit == null) {
myHashLabel.setText("");
myCommitMessage.setText("");
@@ -3,7 +3,7 @@ package com.intellij.vcs.log.ui.tables;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.text.DateFormatUtil;
import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.VcsCommitMiniDetails;
import com.intellij.vcs.log.VcsShortCommitDetails;
import com.intellij.vcs.log.VcsRef;
import com.intellij.vcs.log.data.DataPack;
import com.intellij.vcs.log.data.VcsLogDataHolder;
@@ -53,7 +53,7 @@ public class GraphTableModel extends AbstractTableModel {
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
Node commitNode = dataPack.getGraphModel().getGraph().getCommitNodeInRow(rowIndex);
VcsCommitMiniDetails data;
VcsShortCommitDetails data;
if (commitNode == null) {
data = null;
}
+2 -2
View File
@@ -17,7 +17,7 @@ package git4idea;
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.VcsCommitDetails;
import com.intellij.vcs.log.impl.VcsFullCommitDetailsImpl;
import org.jetbrains.annotations.NotNull;
import java.util.List;
@@ -27,7 +27,7 @@ import java.util.List;
*
* @author Kirill Likhodedov
*/
public final class GitCommit extends VcsCommitDetails {
public final class GitCommit extends VcsFullCommitDetailsImpl {
public GitCommit(@NotNull Hash hash, @NotNull List<Hash> parents, long authorTime, @NotNull String subject, @NotNull String authorName,
@NotNull String authorEmail, @NotNull String message, @NotNull String committerName, @NotNull String committerEmail,
@@ -41,7 +41,8 @@ import com.intellij.util.concurrency.Semaphore;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.TimeCommitParents;
import com.intellij.vcs.log.VcsCommitMiniDetails;
import com.intellij.vcs.log.VcsShortCommitDetails;
import com.intellij.vcs.log.impl.VcsShortCommitDetailsImpl;
import com.intellij.vcs.log.impl.HashImpl;
import git4idea.*;
import git4idea.branch.GitBranchUtil;
@@ -479,7 +480,7 @@ public class GitHistoryUtils {
return null;
}
public static List<? extends VcsCommitMiniDetails> readAllMiniDetails(Project project, VirtualFile root) throws VcsException {
public static List<? extends VcsShortCommitDetails> readAllMiniDetails(Project project, 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_TIME, SUBJECT);
h.setStdoutSuppressed(true);
@@ -492,20 +493,20 @@ public class GitHistoryUtils {
List<GitLogRecord> records = parser.parse(output);
return ContainerUtil.mapNotNull(records, new Function<GitLogRecord, VcsCommitMiniDetails>() {
return ContainerUtil.mapNotNull(records, new Function<GitLogRecord, VcsShortCommitDetails>() {
@Override
public VcsCommitMiniDetails fun(GitLogRecord record) {
public VcsShortCommitDetails fun(GitLogRecord record) {
List<Hash> parents = new SmartList<Hash>();
for (String parent : record.getParentsHashes()) {
parents.add(HashImpl.build(parent));
}
return new VcsCommitMiniDetails(HashImpl.build(record.getHash()), parents, record.getAuthorTimeStamp(),
return new VcsShortCommitDetailsImpl(HashImpl.build(record.getHash()), parents, record.getAuthorTimeStamp(),
record.getSubject(), record.getAuthorName());
}
});
}
public static List<? extends VcsCommitMiniDetails> readMiniDetails(Project project, VirtualFile root, List<String> hashes) throws VcsException {
public static List<? extends VcsShortCommitDetails> readMiniDetails(Project project, 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_TIME, SUBJECT);
h.setStdoutSuppressed(true);
@@ -517,14 +518,14 @@ public class GitHistoryUtils {
String output = h.run();
List<GitLogRecord> records = parser.parse(output);
return ContainerUtil.map(records, new Function<GitLogRecord, VcsCommitMiniDetails>() {
return ContainerUtil.map(records, new Function<GitLogRecord, VcsShortCommitDetails>() {
@Override
public VcsCommitMiniDetails fun(GitLogRecord record) {
public VcsShortCommitDetails fun(GitLogRecord record) {
List<Hash> parents = new SmartList<Hash>();
for (String parent : record.getParentsHashes()) {
parents.add(HashImpl.build(parent));
}
return new VcsCommitMiniDetails(HashImpl.build(record.getHash()), parents, record.getAuthorTimeStamp(),
return new VcsShortCommitDetailsImpl(HashImpl.build(record.getHash()), parents, record.getAuthorTimeStamp(),
record.getSubject(), record.getAuthorName());
}
});
@@ -60,7 +60,7 @@ public class GitLogProvider implements VcsLogProvider {
@NotNull
@Override
public List<? extends VcsCommitDetails> readFirstBlock(@NotNull VirtualFile root, boolean ordered) throws VcsException {
public List<? extends VcsFullCommitDetails> readFirstBlock(@NotNull VirtualFile root, boolean ordered) throws VcsException {
String[] params = { "HEAD", "--branches", "--remotes", "--tags", "--encoding=UTF-8", "--full-history", "--sparse",
"--max-count=" + VcsLogProvider.COMMIT_BLOCK_SIZE};
if (ordered) {
@@ -77,13 +77,13 @@ public class GitLogProvider implements VcsLogProvider {
@NotNull
@Override
public List<? extends VcsCommitMiniDetails> readMiniDetails(@NotNull VirtualFile root, @NotNull List<String> hashes) throws VcsException {
public List<? extends VcsShortCommitDetails> readShortDetails(@NotNull VirtualFile root, @NotNull List<String> hashes) throws VcsException {
return GitHistoryUtils.readMiniDetails(myProject, root, hashes);
}
@NotNull
@Override
public List<? extends VcsCommitDetails> readDetails(@NotNull VirtualFile root, @NotNull List<String> hashes) throws VcsException {
public List<? extends VcsFullCommitDetails> readFullDetails(@NotNull VirtualFile root, @NotNull List<String> hashes) throws VcsException {
return GitHistoryUtils.commitsDetails(myProject, root, hashes);
}
+1
View File
@@ -23,6 +23,7 @@
<orderEntry type="module" module-name="xml-openapi" />
<orderEntry type="module" module-name="xml" />
<orderEntry type="module" module-name="vcs-log-api" />
<orderEntry type="module" module-name="vcs-log-impl" />
</component>
</module>