Add more diagnostics for "CommittedChangesCacheTest"

This commit is contained in:
Konstantin Kolosovsky
2017-06-27 19:39:32 +03:00
parent f87f56d6ae
commit 857b2bf810
4 changed files with 19 additions and 4 deletions
@@ -127,7 +127,7 @@ public class ChangesCacheFile {
closeStreams();
}
catch (IOException e) {
//
LOG.debug(e);
}
}
@@ -453,7 +453,9 @@ public class CommittedChangesCache implements PersistentStateComponent<Committed
@TestOnly
public void refreshAllCaches() throws IOException, VcsException {
debug("Start refreshing all caches");
final Collection<ChangesCacheFile> files = myCachesHolder.getAllCaches();
debug(files.size() + " caches found");
for(ChangesCacheFile file: files) {
if (file.isEmpty()) {
initCache(file);
@@ -462,6 +464,7 @@ public class CommittedChangesCache implements PersistentStateComponent<Committed
refreshCache(file);
}
}
debug("Finished refreshing all caches");
}
private List<CommittedChangeList> initCache(final ChangesCacheFile cacheFile) throws VcsException, IOException {
@@ -503,6 +506,7 @@ public class CommittedChangesCache implements PersistentStateComponent<Committed
// todo: fix - would externally loaded necessarily for file? i.e. just not efficient now
private List<CommittedChangeList> refreshCache(final ChangesCacheFile cacheFile) throws VcsException, IOException {
debug("Refreshing cache for " + cacheFile.getLocation());
final List<CommittedChangeList> newLists = new ArrayList<>();
final CachingCommittedChangesProvider provider = cacheFile.getProvider();
@@ -590,6 +594,8 @@ public class CommittedChangesCache implements PersistentStateComponent<Committed
final List<CommittedChangeList> result = new ArrayList<>();
final Collection<ChangesCacheFile> caches = myCachesHolder.getAllCaches();
debug(caches.size() + " caches found");
final MultiMap<AbstractVcs, Pair<RepositoryLocation, List<CommittedChangeList>>> byVcs =
new MultiMap<>();
@@ -601,6 +607,9 @@ public class CommittedChangesCache implements PersistentStateComponent<Committed
final List<CommittedChangeList> incomingChanges = cache.loadIncomingChanges();
byVcs.putValue(cache.getVcs(), Pair.create(cache.getLocation(), incomingChanges));
}
else {
debug("Empty cache found for " + cache.getLocation());
}
}
catch (IOException e) {
LOG.error(e);
@@ -54,18 +54,23 @@ public class RootsCalculator {
@NotNull
public Map<VirtualFile, RepositoryLocation> getRoots() {
LOG.debug("Collecting roots for " + myVcs);
// TODO: It is not quite clear why using just ProjectLevelVcsManager.getRootsUnderVcs() is not sufficient
List<VirtualFile> roots = getRootsFromMappings();
addAll(roots, myPlManager.getRootsUnderVcs(myVcs));
logRoots("Candidates", roots);
roots.removeIf(file -> getLocation(file) == null);
logRoots("Candidates with repository location", roots);
Map<VirtualFile, RepositoryLocation> result = StreamEx.of(myVcs.filterUniqueRoots(roots, identity()))
.distinct()
.mapToEntry(this::getLocation)
.nonNullValues()
.toMap();
logRoots(result.keySet());
logRoots("Unique roots", result.keySet());
return result;
}
@@ -98,9 +103,9 @@ public class RootsCalculator {
return myLocationCache.getLocation(myVcs, getFilePath(file), false);
}
private static void logRoots(@NotNull Collection<VirtualFile> roots) {
private static void logRoots(@NotNull String prefix, @NotNull Collection<VirtualFile> roots) {
if (LOG.isDebugEnabled()) {
LOG.debug("Roots for committed changes load: " + join(roots, VirtualFile::getPath, ", "));
LOG.debug(prefix + ": " + join(roots, VirtualFile::getPath, ", "));
}
}
}
@@ -74,6 +74,7 @@ public class CommittedChangesCacheTest extends PlatformTestCase {
myVcsManager.setDirectoryMappings(singletonList(new VcsDirectoryMapping("", myVcs.getName())));
myCache = CommittedChangesCache.getInstance(getProject());
assertEquals(1, myCache.getCachesHolder().getAllCaches().size());
myTempDir = createTempDirectory();
myContentRoot = getVirtualFile(myTempDir);