mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[vcs-log] use hash from the indexers in the index id
Theoretically, indexed roots could change with project roots staying the same, for example, when new indexers are implemented for other vcs-es. After this change, index files for old roots won't be deleted. This commit is going to affect projects with both git and mercurial roots, since index id is going to change and old index files won't be deleted. However, this transition will most likely coincide with switching from one version to another, so it should not be a problem. GitOrigin-RevId: 6131752a1338f2c16ae24e2df2d3e49152b8666e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5ca441eff9
commit
e712f2e800
+2
-2
@@ -49,7 +49,7 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import static com.intellij.vcs.log.data.index.VcsLogFullDetailsIndex.INDEX;
|
||||
import static com.intellij.vcs.log.util.PersistentUtil.calcLogId;
|
||||
import static com.intellij.vcs.log.util.PersistentUtil.calcIndexId;
|
||||
|
||||
public class VcsLogPersistentIndex implements VcsLogModifiableIndex, Disposable {
|
||||
private static final Logger LOG = Logger.getInstance(VcsLogPersistentIndex.class);
|
||||
@@ -96,7 +96,7 @@ public class VcsLogPersistentIndex implements VcsLogModifiableIndex, Disposable
|
||||
|
||||
VcsUserRegistry userRegistry = ServiceManager.getService(myProject, VcsUserRegistry.class);
|
||||
|
||||
myIndexStorage = createIndexStorage(fatalErrorsConsumer, myProject.getName(), calcLogId(myProject, providers), userRegistry);
|
||||
myIndexStorage = createIndexStorage(fatalErrorsConsumer, myProject.getName(), calcIndexId(myProject, myIndexers), userRegistry);
|
||||
if (myIndexStorage != null) {
|
||||
myDataGetter = new IndexDataGetter(myProject, myRoots, myIndexStorage, myStorage, myFatalErrorsConsumer);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.util.PathUtilRt
|
||||
import com.intellij.util.indexing.impl.MapIndexStorage
|
||||
import com.intellij.util.io.IOUtil
|
||||
import com.intellij.vcs.log.VcsLogProvider
|
||||
import com.intellij.vcs.log.impl.VcsLogIndexer
|
||||
import com.intellij.vcs.log.util.PersistentUtil.LOG_CACHE
|
||||
import java.io.File
|
||||
import java.nio.file.Path
|
||||
@@ -39,13 +40,19 @@ object PersistentUtil {
|
||||
|
||||
@JvmStatic
|
||||
fun calcLogId(project: Project, logProviders: Map<VirtualFile, VcsLogProvider>): String {
|
||||
val hashcode = calcLogProvidersHash(logProviders)
|
||||
val hashcode = calcHash(logProviders) { it.supportedVcs.name }
|
||||
return project.locationHash + "." + Integer.toHexString(hashcode)
|
||||
}
|
||||
|
||||
private fun calcLogProvidersHash(logProviders: Map<VirtualFile, VcsLogProvider>): Int {
|
||||
@JvmStatic
|
||||
fun calcIndexId(project: Project, logProviders: Map<VirtualFile, VcsLogIndexer>): String {
|
||||
val hashcode = calcHash(logProviders) { it.supportedVcs.name }
|
||||
return project.locationHash + "." + Integer.toHexString(hashcode)
|
||||
}
|
||||
|
||||
private fun <T> calcHash(logProviders: Map<VirtualFile, T>, mapping: (T) -> String): Int {
|
||||
val sortedRoots = logProviders.keys.sortedBy { it.path }
|
||||
return StringUtil.join(sortedRoots, { root -> root.path + "." + logProviders.getValue(root).supportedVcs.name }, ".").hashCode()
|
||||
return StringUtil.join(sortedRoots, { root -> root.path + "." + mapping(logProviders.getValue(root)) }, ".").hashCode()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user