From f371c401cd905f048fe992772d8a4e4eeb7ede1a Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Wed, 13 Nov 2013 16:11:22 +0400 Subject: [PATCH] [log] Remove unused methods & fields "load more details" approach for filtering didn't justify itself, because it was slower, less reliable and occupied much memory. --- .../vcs/log/data/VcsLogDataHolder.java | 135 ------------------ 1 file changed, 135 deletions(-) diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogDataHolder.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogDataHolder.java index 861fd4356a60..ebb7821c729f 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogDataHolder.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogDataHolder.java @@ -89,19 +89,6 @@ public class VcsLogDataHolder implements Disposable { private static final Logger LOG = Logger.getInstance(VcsLogDataHolder.class); - /** - * Don't load more than ourDetailsLoadingRateLimit times of standard recent commits details per repository. - * If this amount of commits is not enough, ask the VCS directly. - */ - private static final int MORE_DETAILS_LOADING_RATE_LIMIT = 10; - - /** - * If more details of recent commits are requested, multiply the number of commits to load by this value on each step, - * until this value reaches {@link #MORE_DETAILS_LOADING_RATE_LIMIT} times of - * {@link VcsLogSettings#getRecentCommitsCount() the standard recent commits count}. - */ - public static final int MORE_DETAILS_LOADING_STEP_MULTIPLIER = 10; - @NotNull private final Project myProject; @NotNull private final VcsLogObjectsFactory myFactory; @NotNull private final Map myLogProviders; @@ -607,86 +594,6 @@ public class VcsLogDataHolder implements Disposable { }); } - /** - * The state of "load more" procedure. - */ - public enum LoadingState { - /** - * currently in the process of loading more details; - */ - LOADING, - /** - * details of all commit of the entire history have been loaded, nothing to load more - */ - ALL_COMMITS_LOADED, - /** - * reached the limit to load more commit details; need to query the VCS directly if needed. - */ - LIMIT_REACHED - } - - @NotNull - public LoadingState loadMoreDetails(@NotNull final Runnable onSuccess) { - if (myLoadMoreInProgress.get()) { // quick check - return LoadingState.LOADING; - } - - final int topCommitsCount = myLogData.getTopCommitsCount(); - int rootsCount = getRootCount(); - if (topCommitsCount >= MORE_DETAILS_LOADING_RATE_LIMIT * mySettings.getRecentCommitsCount() * rootsCount) { - return LoadingState.LIMIT_REACHED; - } - - if (entireLogDetailsLoaded()) { // the entire history was small enough - return LoadingState.ALL_COMMITS_LOADED; - } - - if (myLogData.isFullLogReady()) { - int totalSize = 0; - for (List commits : myLogData.getLogs().values()) { - totalSize += commits.size(); - } - if (topCommitsCount >= totalSize) { - // nothing more to load - return LoadingState.ALL_COMMITS_LOADED; - } - } - - if (myLoadMoreInProgress.compareAndSet(false, true)) { - runInBackground(new ThrowableConsumer() { - @Override - public void consume(ProgressIndicator indicator) throws VcsException { - loadFromVcs(topCommitsCount * MORE_DETAILS_LOADING_STEP_MULTIPLIER, indicator, new Consumer() { - @Override - public void consume(DataPack dataPack) { - myLoadMoreInProgress.set(false); - onSuccess.run(); - } - }); - } - }, "Loading more details to filter..."); - } - return LoadingState.LOADING; - } - - private int getRootCount() { - return myLogProviders.keySet().size(); - } - - private boolean entireLogDetailsLoaded() { - LogData logData = myLogData; - if (logData.isFullLogReady()) { - int totalSize = 0; - for (List commits : logData.getLogs().values()) { - totalSize += commits.size(); - } - if (logData.getTopCommitsCount() >= totalSize) { - return true; - } - } - return false; - } - private void runInBackground(final ThrowableConsumer task, final String title) { myDataLoaderQueue.run(new Task.Backgroundable(myProject, title) { @Override @@ -794,48 +701,6 @@ public class VcsLogDataHolder implements Disposable { return myLogProviders.get(root); } - /** - * Returns the ordered part of the recent commits, details of which are always stored in the cache. - */ - @NotNull - public Collection getTopCommits() { - return myLogData.getTopCommits(); - } - - /** - * Returns details of recent commits ordered in the "right way" (as in the log). - */ - @NotNull - public Collection getTopCommitDetails() { - final Collection topCommits = getTopCommits(); - final AtomicBoolean errorDetailsAttached = new AtomicBoolean(); - return ContainerUtil.mapNotNull(topCommits, new Function() { - @Nullable - @Override - public VcsFullCommitDetails fun(TimedVcsCommit commit) { - Hash hash = commit.getHash(); - VcsFullCommitDetails details = myTopCommitsDetailsCache.get(hash); - if (details != null) { - return details; - } - - // shouldn't happen - String errorMessage = "No details were stored for commit " + hash; - // log the error only once for the getTopCommitDetails request - if (!errorDetailsAttached.get()) { - errorDetailsAttached.set(true); - // temporary disable the error message until the bug is properly fixed. - // the bug is: we store 1000 commit details per root, but iterate through the roots_num * 1000 latest commits - // therefore this error shouldn't happen only in the case when commits of all repositories are evently distributed in time. -// LOG.error(errorMessage, -// new Attachment("details_cache.txt", myTopCommitsDetailsCache.toString()), -// new Attachment("top_commits.txt", topCommits.toString())); - } - return null; - } - }); - } - /** * Simply checks for isDisposed. */