diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogStorageImpl.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogStorageImpl.java index e6559275cf5e..2ede93b681e1 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogStorageImpl.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogStorageImpl.java @@ -24,7 +24,6 @@ import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Ref; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.CommonProcessors; -import com.intellij.util.Consumer; import com.intellij.util.io.IOUtil; import com.intellij.util.io.KeyDescriptor; import com.intellij.util.io.PersistentEnumeratorBase; @@ -38,9 +37,7 @@ import one.util.streamex.StreamEx; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; +import java.io.*; import java.util.List; import java.util.Map; @@ -54,6 +51,7 @@ public class VcsLogStorageImpl implements Disposable, VcsLogStorage { @NotNull public static final VcsLogStorage EMPTY = new EmptyLogStorage(); public static final int VERSION = 5; + private static final int REFS_VERSION = 1; @NotNull private static final String ROOT_STORAGE_KIND = "roots"; private static final int ROOTS_STORAGE_VERSION = 0; @@ -76,7 +74,8 @@ public class VcsLogStorageImpl implements Disposable, VcsLogStorage { MyCommitIdKeyDescriptor commitIdKeyDescriptor = new MyCommitIdKeyDescriptor(roots); myCommitIdEnumerator = PersistentUtil.createPersistentEnumerator(commitIdKeyDescriptor, HASHES_STORAGE, logId, VERSION); myRefsEnumerator = - PersistentUtil.createPersistentEnumerator(new VcsRefKeyDescriptor(logProviders, commitIdKeyDescriptor), REFS_STORAGE, logId, VERSION); + PersistentUtil.createPersistentEnumerator(new VcsRefKeyDescriptor(logProviders, commitIdKeyDescriptor), REFS_STORAGE, logId, + VERSION + REFS_VERSION); // cleanup old root storages, to remove after 2016.3 release PersistentUtil @@ -278,10 +277,7 @@ public class VcsLogStorageImpl implements Disposable, VcsLogStorage { @Override public int getHashCode(@NotNull VcsRef value) { - int result = new CommitId(value.getCommitHash(), value.getRoot()).hashCode(); - result = 31 * result + value.getName().hashCode(); - result = 31 * result + value.getType().hashCode(); - return result; + return value.hashCode(); } @Override diff --git a/plugins/git4idea/src/git4idea/log/GitRefManager.java b/plugins/git4idea/src/git4idea/log/GitRefManager.java index d7d10bc94ab0..8713ddc395be 100644 --- a/plugins/git4idea/src/git4idea/log/GitRefManager.java +++ b/plugins/git4idea/src/git4idea/log/GitRefManager.java @@ -294,6 +294,19 @@ public class GitRefManager implements VcsLogRefManager { public String toString() { return myName; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + SimpleRefType type = (SimpleRefType)o; + return myIsBranch == type.myIsBranch && Objects.equals(myName, type.myName); + } + + @Override + public int hashCode() { + return Objects.hash(myIsBranch, myName); + } } private static class LogicalRefGroup implements RefGroup { diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/log/HgRefManager.java b/plugins/hg4idea/src/org/zmlx/hg4idea/log/HgRefManager.java index 2aace92a9c67..ae96baf9b2cd 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/log/HgRefManager.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/log/HgRefManager.java @@ -36,14 +36,14 @@ public class HgRefManager implements VcsLogRefManager { private static final Color LOCAL_TAG_COLOR = new JBColor(new Color(0x009090), new Color(0x00f3f3)); private static final Color MQ_TAG_COLOR = new JBColor(new Color(0x002f90), new Color(0x0055ff)); - public static final VcsRefType TIP = new SimpleRefType(true, VcsLogStandardColors.Refs.TIP); - public static final VcsRefType HEAD = new SimpleRefType(true, VcsLogStandardColors.Refs.LEAF); - public static final VcsRefType BRANCH = new SimpleRefType(true, VcsLogStandardColors.Refs.BRANCH); - public static final VcsRefType CLOSED_BRANCH = new SimpleRefType(false, CLOSED_BRANCH_COLOR); - public static final VcsRefType BOOKMARK = new SimpleRefType(true, VcsLogStandardColors.Refs.BRANCH_REF); - public static final VcsRefType TAG = new SimpleRefType(false, VcsLogStandardColors.Refs.TAG); - public static final VcsRefType LOCAL_TAG = new SimpleRefType(false, LOCAL_TAG_COLOR); - public static final VcsRefType MQ_APPLIED_TAG = new SimpleRefType(false, MQ_TAG_COLOR); + public static final VcsRefType TIP = new SimpleRefType("TIP", true, VcsLogStandardColors.Refs.TIP); + public static final VcsRefType HEAD = new SimpleRefType("HEAD", true, VcsLogStandardColors.Refs.LEAF); + public static final VcsRefType BRANCH = new SimpleRefType("BRANCH", true, VcsLogStandardColors.Refs.BRANCH); + public static final VcsRefType CLOSED_BRANCH = new SimpleRefType("CLOSED_BRANCH", false, CLOSED_BRANCH_COLOR); + public static final VcsRefType BOOKMARK = new SimpleRefType("BOOKMARK", true, VcsLogStandardColors.Refs.BRANCH_REF); + public static final VcsRefType TAG = new SimpleRefType("TAG", false, VcsLogStandardColors.Refs.TAG); + public static final VcsRefType LOCAL_TAG = new SimpleRefType("LOCAL_TAG", false, LOCAL_TAG_COLOR); + public static final VcsRefType MQ_APPLIED_TAG = new SimpleRefType("MQ_TAG", false, MQ_TAG_COLOR); // first has the highest priority private static final List REF_TYPE_PRIORITIES = Arrays.asList(TIP, HEAD, BRANCH, BOOKMARK, TAG); @@ -159,10 +159,12 @@ public class HgRefManager implements VcsLogRefManager { } private static class SimpleRefType implements VcsRefType { + @NotNull private final String myName; private final boolean myIsBranch; @NotNull private final Color myColor; - public SimpleRefType(boolean isBranch, @NotNull Color color) { + public SimpleRefType(@NotNull String name, boolean isBranch, @NotNull Color color) { + myName = name; myIsBranch = isBranch; myColor = color; } @@ -177,6 +179,19 @@ public class HgRefManager implements VcsLogRefManager { public Color getBackgroundColor() { return myColor; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + SimpleRefType type = (SimpleRefType)o; + return myIsBranch == type.myIsBranch && Objects.equals(myName, type.myName); + } + + @Override + public int hashCode() { + return Objects.hash(myName, myIsBranch); + } } private static class SimpleRefGroup implements RefGroup {