mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
new git log, faster
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package git4idea.history;
|
||||
|
||||
import com.intellij.execution.process.ProcessOutputTypes;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
@@ -35,10 +36,7 @@ import com.intellij.util.concurrency.Semaphore;
|
||||
import com.intellij.util.text.StringTokenizer;
|
||||
import com.intellij.vcsUtil.VcsUtil;
|
||||
import git4idea.*;
|
||||
import git4idea.commands.GitCommand;
|
||||
import git4idea.commands.GitLineHandler;
|
||||
import git4idea.commands.GitLineHandlerAdapter;
|
||||
import git4idea.commands.GitSimpleHandler;
|
||||
import git4idea.commands.*;
|
||||
import git4idea.history.browser.GitCommit;
|
||||
import git4idea.history.browser.SHAHash;
|
||||
import git4idea.history.wholeTree.CommitHashPlusParents;
|
||||
@@ -427,7 +425,7 @@ public class GitHistoryUtils {
|
||||
h.setNoSSH(true);
|
||||
h.setStdoutSuppressed(true);
|
||||
h.addParameters(parameters);
|
||||
h.addParameters("--name-only", "--pretty=format:%x03%H%x00%ct%x00", "--encoding=UTF-8");
|
||||
h.addParameters("--pretty=format:%x03%H%x00%ct%x00", "--encoding=UTF-8");
|
||||
h.endOptions();
|
||||
h.addRelativePaths(path);
|
||||
String output = h.run();
|
||||
@@ -566,39 +564,51 @@ public class GitHistoryUtils {
|
||||
// adjust path using change manager
|
||||
path = getLastCommitName(project, path);
|
||||
final VirtualFile root = GitUtil.getGitRoot(path);
|
||||
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.LOG);
|
||||
GitLineHandler h = new GitLineHandler(project, root, GitCommand.LOG);
|
||||
h.setNoSSH(true);
|
||||
h.setStdoutSuppressed(true);
|
||||
h.addParameters(parameters);
|
||||
h.addParameters("--name-only", "--pretty=format:%x01%h%x00%ct%x00%p", "--encoding=UTF-8");
|
||||
h.addParameters("--pretty=format:%x01%h%x00%ct%x00%p", "--encoding=UTF-8");
|
||||
|
||||
h.endOptions();
|
||||
h.addRelativePaths(path);
|
||||
String output = h.run();
|
||||
final List<CommitHashPlusParents> rc = new ArrayList<CommitHashPlusParents>();
|
||||
StringTokenizer tk = new StringTokenizer(output, "\u0001", false);
|
||||
|
||||
while (tk.hasMoreTokens()) {
|
||||
final String line = tk.nextToken();
|
||||
final String[] subLines = line.split("\n");
|
||||
final StringTokenizer tk2 = new StringTokenizer(subLines[0], "\u0000", false);
|
||||
h.addLineListener(new GitLineHandlerListener() {
|
||||
@Override
|
||||
public void onLineAvailable(final String line, final Key outputType) {
|
||||
if (ProcessOutputTypes.STDOUT.equals(outputType)) {
|
||||
if (line.startsWith("\u0001")) {
|
||||
final StringTokenizer tk2 = new StringTokenizer(line.substring(1), "\u0000", false);
|
||||
|
||||
final String hash = tk2.nextToken();
|
||||
final long time;
|
||||
if (tk2.hasMoreTokens()) {
|
||||
final String dateString = tk2.nextToken();
|
||||
time = Long.parseLong(dateString.trim());
|
||||
} else {
|
||||
time = 0;
|
||||
final String hash = tk2.nextToken();
|
||||
final long time;
|
||||
if (tk2.hasMoreTokens()) {
|
||||
final String dateString = tk2.nextToken();
|
||||
time = Long.parseLong(dateString.trim());
|
||||
} else {
|
||||
time = 0;
|
||||
}
|
||||
final String[] parents;
|
||||
if (tk2.hasMoreTokens()) {
|
||||
parents = tk2.nextToken().split(" ");
|
||||
} else {
|
||||
parents = ArrayUtil.EMPTY_STRING_ARRAY;
|
||||
}
|
||||
consumer.consume(new CommitHashPlusParents(hash, parents, time)); // todo stop listen to output
|
||||
}
|
||||
}
|
||||
}
|
||||
final String[] parents;
|
||||
if (tk2.hasMoreTokens()) {
|
||||
parents = tk2.nextToken().split(" ");
|
||||
} else {
|
||||
parents = ArrayUtil.EMPTY_STRING_ARRAY;
|
||||
|
||||
@Override
|
||||
public void processTerminated(int exitCode) {
|
||||
}
|
||||
consumer.consume(new CommitHashPlusParents(hash, parents, time));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startFailed(Throwable exception) {
|
||||
// todo
|
||||
}
|
||||
});
|
||||
h.start();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -18,7 +18,6 @@ package git4idea.history.wholeTree;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.vcs.BigArray;
|
||||
|
||||
/**
|
||||
* @author irengrig
|
||||
@@ -30,27 +29,6 @@ public class FictiveAction extends AnAction {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final BigArray<VisibleLine> ba = new BigArray<VisibleLine>(4);
|
||||
for (int i = 0; i < 100; i++) {
|
||||
ba.add(new MyLine("Test" + i));
|
||||
}
|
||||
GitLogLongPanel.showDialog(PlatformDataKeys.PROJECT.getData(e.getDataContext()));
|
||||
}
|
||||
|
||||
private static class MyLine implements VisibleLine {
|
||||
private final String myLine;
|
||||
|
||||
public MyLine(String line) {
|
||||
myLine = line;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getData() {
|
||||
return myLine;
|
||||
}
|
||||
@Override
|
||||
public boolean isDecoration() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,6 +196,11 @@ public class GitLogLongPanel {
|
||||
new MyDialog(project, gitLogLongPanel).show();
|
||||
}
|
||||
|
||||
public static void showDialog(final Project project, final VirtualFile root) {
|
||||
final GitLogLongPanel gitLogLongPanel = new GitLogLongPanel(project, Collections.singletonList(root));
|
||||
new MyDialog(project, gitLogLongPanel).show();
|
||||
}
|
||||
|
||||
public UIRefresh getUIRefresh() {
|
||||
return myUIRefresh;
|
||||
}
|
||||
@@ -291,8 +296,8 @@ public class GitLogLongPanel {
|
||||
myTimer = new Timer(100, new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
//final boolean shouldPing = (System.currentTimeMillis() - myRefreshMark) > 700;
|
||||
final boolean shouldPing = false;
|
||||
final boolean shouldPing = (System.currentTimeMillis() - myRefreshMark) > 300;
|
||||
//final boolean shouldPing = false;
|
||||
if (((mySpeedometer.getSpeed() < 0.1) && mySpeedometer.hasData()) || shouldPing) {
|
||||
myRefreshMark = System.currentTimeMillis();
|
||||
mySpeedometer.clear();
|
||||
|
||||
@@ -269,7 +269,7 @@ public class LoaderImpl implements Loader {
|
||||
@Override
|
||||
public void consume(List<CommitHashPlusParents> commitHashPlusParentses) {
|
||||
synchronized (myLock) {
|
||||
if (myId != myLoadId) throw new MyStopListenToOutputException();
|
||||
if (myId != myLoadId) throw new MyStopListenToOutputException(); // TODO TODO TODO
|
||||
}
|
||||
for (CommitHashPlusParents item : commitHashPlusParentses) {
|
||||
myConsumer.consume(item);
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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 git4idea.history.wholeTree;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.fileChooser.FileChooser;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
/**
|
||||
* @author irengrig
|
||||
*/
|
||||
public class SelectRepositoryAndShowLogAction extends AnAction {
|
||||
public SelectRepositoryAndShowLogAction() {
|
||||
super("Select and browse git repo");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
|
||||
final VirtualFile[] virtualFiles = FileChooser.chooseFiles(project, new FileChooserDescriptor(false, true, false, true, false, false));
|
||||
if (virtualFiles == null || virtualFiles.length == 0) return;
|
||||
GitLogLongPanel.showDialog(project, virtualFiles[0]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user