mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[log] Let VcsLogObjectsFactory be project service & depend on VcsLogManager
This will allow the factory implementation to access data stored in the VcsLogDataHolder, etc. Will be used later for collecting the list of commit authors.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
<changesViewContent tabName="Log" className="com.intellij.vcs.log.impl.VcsLogContentProvider"
|
||||
predicateClassName="com.intellij.vcs.log.impl.VcsLogContentProvider"/>
|
||||
|
||||
<applicationService serviceInterface="com.intellij.vcs.log.VcsLogObjectsFactory" serviceImplementation="com.intellij.vcs.log.impl.VcsLogObjectsFactoryImpl" />
|
||||
<projectService serviceInterface="com.intellij.vcs.log.VcsLogObjectsFactory" serviceImplementation="com.intellij.vcs.log.impl.VcsLogObjectsFactoryImpl" />
|
||||
<projectService serviceInterface="com.intellij.vcs.log.impl.VcsLogManager" serviceImplementation="com.intellij.vcs.log.impl.VcsLogManager"/>
|
||||
<projectService serviceInterface="com.intellij.vcs.log.VcsLogSettings" serviceImplementation="com.intellij.vcs.log.impl.VcsLogSettingsImpl"/>
|
||||
<projectService serviceInterface="com.intellij.vcs.log.data.VcsLogUiProperties" serviceImplementation="com.intellij.vcs.log.data.VcsLogUiProperties"/>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.vcs.log.data;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.diagnostic.Attachment;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.BackgroundTaskQueue;
|
||||
@@ -154,7 +155,7 @@ public class VcsLogDataHolder implements Disposable {
|
||||
*/
|
||||
private CountDownLatch myEntireLogLoadWaiter;
|
||||
|
||||
public VcsLogDataHolder(@NotNull Project project, @NotNull VcsLogObjectsFactory logObjectsFactory,
|
||||
public VcsLogDataHolder(@NotNull Project project,
|
||||
@NotNull Map<VirtualFile, VcsLogProvider> logProviders, @NotNull VcsLogSettings settings) {
|
||||
myProject = project;
|
||||
myLogProviders = logProviders;
|
||||
@@ -163,7 +164,7 @@ public class VcsLogDataHolder implements Disposable {
|
||||
myDetailsGetter = new CommitDetailsGetter(this, logProviders);
|
||||
myLogJoiner = new VcsLogJoiner();
|
||||
myMultiRepoJoiner = new VcsLogMultiRepoJoiner();
|
||||
myFactory = logObjectsFactory;
|
||||
myFactory = ServiceManager.getService(myProject, VcsLogObjectsFactory.class);
|
||||
mySettings = settings;
|
||||
}
|
||||
|
||||
@@ -178,10 +179,10 @@ public class VcsLogDataHolder implements Disposable {
|
||||
* @param settings
|
||||
* @param onInitialized This is called when the holder is initialized with the initial data received from the VCS.
|
||||
*/
|
||||
public static void init(@NotNull final Project project, @NotNull VcsLogObjectsFactory logObjectsFactory,
|
||||
public static void init(@NotNull final Project project,
|
||||
@NotNull Map<VirtualFile, VcsLogProvider> logProviders,
|
||||
@NotNull VcsLogSettings settings, @NotNull final Consumer<VcsLogDataHolder> onInitialized) {
|
||||
final VcsLogDataHolder dataHolder = new VcsLogDataHolder(project, logObjectsFactory, logProviders, settings);
|
||||
final VcsLogDataHolder dataHolder = new VcsLogDataHolder(project, logProviders, settings);
|
||||
dataHolder.initialize(onInitialized);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.intellij.ui.content.ContentManagerEvent;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import com.intellij.vcs.log.VcsLogObjectsFactory;
|
||||
import com.intellij.vcs.log.VcsLogProvider;
|
||||
import com.intellij.vcs.log.VcsLogRefresher;
|
||||
import com.intellij.vcs.log.VcsLogSettings;
|
||||
@@ -45,7 +44,6 @@ public class VcsLogManager implements Disposable {
|
||||
|
||||
@NotNull private final Project myProject;
|
||||
@NotNull private final ProjectLevelVcsManager myVcsManager;
|
||||
@NotNull private final VcsLogObjectsFactory myLogObjectsFactory;
|
||||
@NotNull private final VcsLogSettings mySettings;
|
||||
@NotNull private final VcsLogUiProperties myUiProperties;
|
||||
|
||||
@@ -54,11 +52,10 @@ public class VcsLogManager implements Disposable {
|
||||
private VcsLogUI myUi;
|
||||
|
||||
public VcsLogManager(@NotNull Project project, @NotNull ProjectLevelVcsManager vcsManager,
|
||||
@NotNull VcsLogObjectsFactory logObjectsFactory, @NotNull VcsLogSettings settings,
|
||||
@NotNull VcsLogSettings settings,
|
||||
@NotNull VcsLogUiProperties uiProperties) {
|
||||
myProject = project;
|
||||
myVcsManager = vcsManager;
|
||||
myLogObjectsFactory = logObjectsFactory;
|
||||
mySettings = settings;
|
||||
myUiProperties = uiProperties;
|
||||
Disposer.register(myProject, this);
|
||||
@@ -69,7 +66,7 @@ public class VcsLogManager implements Disposable {
|
||||
final Map<VirtualFile, VcsLogProvider> logProviders = findLogProviders();
|
||||
final VcsLogContainer mainPanel = new VcsLogContainer(myProject);
|
||||
|
||||
VcsLogDataHolder.init(myProject, myLogObjectsFactory, logProviders, mySettings, new Consumer<VcsLogDataHolder>() {
|
||||
VcsLogDataHolder.init(myProject, logProviders, mySettings, new Consumer<VcsLogDataHolder>() {
|
||||
@Override
|
||||
public void consume(VcsLogDataHolder vcsLogDataHolder) {
|
||||
Disposer.register(VcsLogManager.this, vcsLogDataHolder);
|
||||
|
||||
@@ -12,6 +12,12 @@ import java.util.List;
|
||||
*/
|
||||
public class VcsLogObjectsFactoryImpl implements VcsLogObjectsFactory {
|
||||
|
||||
@NotNull private final VcsLogManager myLogManager;
|
||||
|
||||
public VcsLogObjectsFactoryImpl(@NotNull VcsLogManager logManager) {
|
||||
myLogManager = logManager;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Hash createHash(@NotNull String stringHash) {
|
||||
|
||||
@@ -198,7 +198,7 @@ public class GitCherryPickAction extends DumbAwareAction {
|
||||
return ContainerUtil.map(commits, new Function<GitHeavyCommit, VcsFullCommitDetails>() {
|
||||
@Override
|
||||
public VcsFullCommitDetails fun(GitHeavyCommit commit) {
|
||||
final VcsLogObjectsFactory factory = ServiceManager.getService(VcsLogObjectsFactory.class);
|
||||
final VcsLogObjectsFactory factory = ServiceManager.getService(project, VcsLogObjectsFactory.class);
|
||||
List<Hash> parents = ContainerUtil.map(commit.getParentsHashes(), new Function<String, Hash>() {
|
||||
@Override
|
||||
public Hash fun(String hashValue) {
|
||||
|
||||
@@ -535,7 +535,7 @@ public class GitHistoryUtils {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<TimedVcsCommit> readAllHashes(@NotNull Project project, @NotNull VirtualFile root) throws VcsException {
|
||||
public static List<TimedVcsCommit> readAllHashes(@NotNull final Project project, @NotNull VirtualFile root) throws VcsException {
|
||||
final int COMMIT_BUFFER = 1000;
|
||||
|
||||
GitLineHandler h = new GitLineHandler(project, root, GitCommand.LOG);
|
||||
@@ -571,7 +571,7 @@ public class GitHistoryUtils {
|
||||
afterParseRemainder = line.substring(recordEnd + 1);
|
||||
}
|
||||
if (afterParseRemainder != null && records.incrementAndGet() > COMMIT_BUFFER) { // null means can't parse now
|
||||
commits.addAll(parseCommit(parser, record));
|
||||
commits.addAll(parseCommit(project, parser, record));
|
||||
record.setLength(0);
|
||||
record.append(afterParseRemainder);
|
||||
}
|
||||
@@ -584,7 +584,7 @@ public class GitHistoryUtils {
|
||||
@Override
|
||||
public void processTerminated(int exitCode) {
|
||||
try {
|
||||
commits.addAll(parseCommit(parser, record));
|
||||
commits.addAll(parseCommit(project, parser, record));
|
||||
}
|
||||
catch (Exception e) {
|
||||
ex.set(new VcsException(e));
|
||||
@@ -603,19 +603,19 @@ public class GitHistoryUtils {
|
||||
return commits;
|
||||
}
|
||||
|
||||
private static List<TimedVcsCommit> parseCommit(GitLogParser parser, StringBuilder record) {
|
||||
private static List<TimedVcsCommit> parseCommit(final Project project, GitLogParser parser, StringBuilder record) {
|
||||
List<GitLogRecord> rec = parser.parse(record.toString());
|
||||
return ContainerUtil.mapNotNull(rec, new Function<GitLogRecord, TimedVcsCommit>() {
|
||||
@Override
|
||||
public TimedVcsCommit fun(GitLogRecord record) {
|
||||
return record == null ? null : convert(record);
|
||||
return (record == null) ? null : convert(project, record);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static TimedVcsCommit convert(GitLogRecord rec) {
|
||||
VcsLogObjectsFactory factory = ServiceManager.getService(VcsLogObjectsFactory.class);
|
||||
private static TimedVcsCommit convert(Project project, GitLogRecord rec) {
|
||||
VcsLogObjectsFactory factory = ServiceManager.getService(project, VcsLogObjectsFactory.class);
|
||||
List<Hash> parents = ContainerUtil.map(rec.getParentsHashes(), new Function<String, Hash>() {
|
||||
@Override
|
||||
public Hash fun(String s) {
|
||||
|
||||
@@ -66,7 +66,7 @@ public class GitLogProvider implements VcsLogProvider {
|
||||
myProject = project;
|
||||
myRepositoryManager = repositoryManager;
|
||||
myRefSorter = new GitRefManager(myRepositoryManager);
|
||||
myVcsObjectsFactory = ServiceManager.getService(VcsLogObjectsFactory.class);
|
||||
myVcsObjectsFactory = ServiceManager.getService(myProject, VcsLogObjectsFactory.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -262,7 +262,7 @@ public class GitCherryPickStepdefs {
|
||||
private static VcsFullCommitDetails mockCommit(String hash, String message) {
|
||||
List<Change> changes = new ArrayList<Change>();
|
||||
changes.add(new Change(null, new MockContentRevision(new FilePathImpl(new MockVirtualFile("name")), VcsRevisionNumber.NULL)));
|
||||
return ServiceManager.getService(VcsLogObjectsFactory.class).createFullDetails(
|
||||
return ServiceManager.getService(myProject, VcsLogObjectsFactory.class).createFullDetails(
|
||||
HashImpl.build(hash), Collections.<Hash>emptyList(), 0, NullVirtualFile.INSTANCE, message, "John Smith", "john@mail.com", message,
|
||||
"John Smith", "john@mail.com", 0, changes, GitContentRevisionFactory.getInstance(myProject));
|
||||
}
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ public class GithubShowCommitInBrowserFromLogAction extends GithubShowCommitInBr
|
||||
private static VcsShortCommitDetails getCurrentlySelectedCommitInTheLog(AnActionEvent e) {
|
||||
GitHeavyCommit heavyCommit = e.getData(GitVcs.GIT_COMMIT);
|
||||
if (heavyCommit != null) {
|
||||
final VcsLogObjectsFactory factory = ServiceManager.getService(VcsLogObjectsFactory.class);
|
||||
final VcsLogObjectsFactory factory = ServiceManager.getService(e.getProject(), VcsLogObjectsFactory.class);
|
||||
List<Hash> parents = ContainerUtil.map(heavyCommit.getParentsHashes(), new Function<String, Hash>() {
|
||||
@Override
|
||||
public Hash fun(String s) {
|
||||
|
||||
@@ -62,7 +62,7 @@ public class HgLogProvider implements VcsLogProvider {
|
||||
myProject = project;
|
||||
myRepositoryManager = repositoryManager;
|
||||
myRefSorter = new HgRefManager();
|
||||
myVcsObjectsFactory = ServiceManager.getService(VcsLogObjectsFactory.class);
|
||||
myVcsObjectsFactory = ServiceManager.getService(project, VcsLogObjectsFactory.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -51,7 +51,7 @@ public class HgRepositoryImpl extends RepositoryImpl implements HgRepository {
|
||||
super(project, rootDir, parentDisposable);
|
||||
myHgDir = rootDir.findChild(HgUtil.DOT_HG);
|
||||
assert myHgDir != null : ".hg directory wasn't found under " + rootDir.getPresentableUrl();
|
||||
myReader = new HgRepositoryReader(VfsUtilCore.virtualToIoFile(myHgDir));
|
||||
myReader = new HgRepositoryReader(project, VfsUtilCore.virtualToIoFile(myHgDir));
|
||||
myConfig = HgConfig.getInstance(project, rootDir);
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.dvcs.repo.RepoStateException;
|
||||
import com.intellij.dvcs.repo.Repository;
|
||||
import com.intellij.dvcs.repo.RepositoryUtil;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.vcs.log.VcsLogObjectsFactory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -49,7 +50,7 @@ public class HgRepositoryReader {
|
||||
@NotNull private final File myLocalTagsFile; // .hg/localtags
|
||||
@NotNull private final VcsLogObjectsFactory myVcsObjectsFactory;
|
||||
|
||||
public HgRepositoryReader(@NotNull File hgDir) {
|
||||
public HgRepositoryReader(@NotNull Project project, @NotNull File hgDir) {
|
||||
myHgDir = hgDir;
|
||||
RepositoryUtil.assertFileExists(myHgDir, ".hg directory not found in " + myHgDir);
|
||||
File branchesFile = new File(new File(myHgDir, "cache"), "branchheads-served"); //branchheads-served exist after mercurial 2.5,
|
||||
@@ -60,7 +61,7 @@ public class HgRepositoryReader {
|
||||
myCurrentBookmark = new File(myHgDir, "bookmarks.current");
|
||||
myLocalTagsFile = new File(myHgDir, "localtags");
|
||||
myTagsFile = new File(myHgDir.getParentFile(), ".hgtags");
|
||||
myVcsObjectsFactory = ServiceManager.getService(VcsLogObjectsFactory.class);
|
||||
myVcsObjectsFactory = ServiceManager.getService(project, VcsLogObjectsFactory.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -120,7 +120,7 @@ public class HgHistoryUtil {
|
||||
@NotNull
|
||||
public static List<? extends VcsShortCommitDetails> readMiniDetails(Project project, final VirtualFile root, List<String> hashes)
|
||||
throws VcsException {
|
||||
final VcsLogObjectsFactory factory = ServiceManager.getService(VcsLogObjectsFactory.class);
|
||||
final VcsLogObjectsFactory factory = ServiceManager.getService(project, VcsLogObjectsFactory.class);
|
||||
return ContainerUtil.map(getCommittedChangeList(project, root, -1, false, prepareHashes(hashes)),
|
||||
new Function<HgCommittedChangeList, VcsShortCommitDetails>() {
|
||||
@Override
|
||||
@@ -140,7 +140,7 @@ public class HgHistoryUtil {
|
||||
@NotNull
|
||||
public static List<TimedVcsCommit> readAllHashes(@NotNull Project project, @NotNull VirtualFile root) throws VcsException {
|
||||
|
||||
final VcsLogObjectsFactory factory = ServiceManager.getService(VcsLogObjectsFactory.class);
|
||||
final VcsLogObjectsFactory factory = ServiceManager.getService(project, VcsLogObjectsFactory.class);
|
||||
return ContainerUtil.map(getCommittedChangeList(project, root, -1, false, ""), new Function<HgCommittedChangeList, TimedVcsCommit>() {
|
||||
@Override
|
||||
public TimedVcsCommit fun(HgCommittedChangeList record) {
|
||||
@@ -174,7 +174,7 @@ public class HgHistoryUtil {
|
||||
private static VcsFullCommitDetails createCommit(@NotNull Project project, @NotNull VirtualFile root,
|
||||
@NotNull HgCommittedChangeList record) {
|
||||
|
||||
final VcsLogObjectsFactory factory = ServiceManager.getService(VcsLogObjectsFactory.class);
|
||||
final VcsLogObjectsFactory factory = ServiceManager.getService(project, VcsLogObjectsFactory.class);
|
||||
HgRevisionNumber revNumber = (HgRevisionNumber)record.getRevisionNumber();
|
||||
|
||||
List<Hash> parents = ContainerUtil.map(revNumber.getParents(), new Function<HgRevisionNumber, Hash>() {
|
||||
|
||||
@@ -41,7 +41,7 @@ public class HgRealRepositoryReaderTest extends HgPlatformTest {
|
||||
File hgDir = new File(myRepository.getPath(), ".hg");
|
||||
assertTrue(hgDir.exists());
|
||||
createBranchesAndTags();
|
||||
myRepositoryReader = new HgRepositoryReader(hgDir);
|
||||
myRepositoryReader = new HgRepositoryReader(myProject, hgDir);
|
||||
}
|
||||
|
||||
public void testMergeState() {
|
||||
|
||||
@@ -63,7 +63,7 @@ public class HgRepositoryReaderTest extends HgPlatformTest {
|
||||
FileUtil.copy(testTagFile, new File(myHgDir.getParentFile(), ".hgtags"));
|
||||
FileUtil.copy(testLocalTagFile, new File(myHgDir, "localtags"));
|
||||
|
||||
myRepositoryReader = new HgRepositoryReader(myHgDir);
|
||||
myRepositoryReader = new HgRepositoryReader(myProject, myHgDir);
|
||||
myBranches = readBranches();
|
||||
myBookmarks = readRefs(testBookmarkFile);
|
||||
myTags = readRefs(testTagFile);
|
||||
|
||||
Reference in New Issue
Block a user