/*
 * Copyright 2000-2015 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;

import com.intellij.openapi.util.Condition;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
 * Map of {@link Hash} to <b>{@code int}</b>.
 */
public interface VcsLogStorage {

  int getCommitIndex(@NotNull Hash hash, @NotNull VirtualFile root);

  @Nullable
  CommitId getCommitId(int commitIndex);

  /**
   * Iterates over known commit ids to find the first one which satisfies given condition.
   *
   * @return
   */
  @Nullable
  CommitId findCommitId(@NotNull Condition<CommitId> condition);

  int getRefIndex(@NotNull VcsRef ref);

  @Nullable
  VcsRef getVcsRef(int refIndex);

  void flush();
}

@@ -811,158 +811,796 @@
 %0A * 
-Map of %7B@link Hash%7D to %3Cb%3E%7B@code int%7D%3C/b%3E.%0A */%0Apublic interface VcsLogStorage %7B%0A%0A  int getCommitIndex(@NotNull Hash hash, @NotNull VirtualFile root);%0A
+Storage for various Log objects like CommitId or VcsRef%0A * which quantity is to big to keep them in memory.%0A * VcsLogStorage keeps a mapping from integers to those objects%0A * allowing to operate with integers, not the objects themselves.%0A */%0Apublic interface VcsLogStorage %7B%0A%0A  /**%0A   * Returns an integer index that is a unique identifier for a commit with specified hash and root.%0A   *%0A   * @param hash commit hash%0A   * @param root root of the repository for the commit%0A   * @return a commit index%0A   */%0A  int getCommitIndex(@NotNull Hash hash, @NotNull VirtualFile root);%0A%0A  /**%0A   * Returns a commit for a specified index or null if this index does not correspond to any commit.%0A   *%0A   * @param commitIndex index of a commit%0A   * @return commit identified by this index or null%0A   */
 %0A  @
@@ -1764,16 +1764,81 @@
  @return
+ matching commit or null if no commit matches the given condition
 %0A   */%0A 
@@ -1920,93 +1920,531 @@
 %0A%0A  
-int getRefIndex(@NotNull VcsRef ref);%0A%0A  @Nullable%0A  VcsRef getVcsRef(int refIndex);%0A
+/**%0A   * Returns an integer index that is a unique identifier for a reference.%0A   *%0A   * @param ref reference%0A   * @return a reference index%0A   */%0A  int getRefIndex(@NotNull VcsRef ref);%0A%0A  /**%0A   * Returns a reference for a specified index or null if this index does not correspond to any reference.%0A   *%0A   * @param refIndex index of a reference%0A   * @return reference identified by this index or null%0A   */%0A  @Nullable%0A  VcsRef getVcsRef(int refIndex);%0A%0A  /**%0A   * Forces data in the storage to be written on disk.%0A   */
 %0A  v

add javadoc