From a041f5e43b2007bbb9fe4451c73afb864d47277e Mon Sep 17 00:00:00 2001 From: Dmytro Kashyn <50216138+dkashyn-sfdc@users.noreply.github.com> Date: Wed, 30 Oct 2024 11:11:27 -0400 Subject: [PATCH] Use git info only when Expand to Working Set is enabled (#6944) --- .../blaze/base/qsync/ProjectQuerierImpl.java | 21 +++++++++++-------- .../blaze/base/sync/ProjectStateSyncTask.java | 3 ++- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/base/src/com/google/idea/blaze/base/qsync/ProjectQuerierImpl.java b/base/src/com/google/idea/blaze/base/qsync/ProjectQuerierImpl.java index a0232f05dc2..e0d71ab7663 100644 --- a/base/src/com/google/idea/blaze/base/qsync/ProjectQuerierImpl.java +++ b/base/src/com/google/idea/blaze/base/qsync/ProjectQuerierImpl.java @@ -22,6 +22,7 @@ import com.google.idea.blaze.base.logging.utils.querysync.SyncQueryStats; import com.google.idea.blaze.base.logging.utils.querysync.SyncQueryStatsScope; import com.google.idea.blaze.base.scope.BlazeContext; +import com.google.idea.blaze.base.settings.BlazeUserSettings; import com.google.idea.blaze.base.vcs.BlazeVcsHandlerProvider.BlazeVcsHandler; import com.google.idea.blaze.common.vcs.VcsState; import com.google.idea.blaze.exception.BuildException; @@ -120,15 +121,17 @@ public PostQuerySyncData update( ProjectDefinition currentProjectDef, PostQuerySyncData previousState, BlazeContext context) throws IOException, BuildException { - Optional vcsState = getVcsState(context); - SyncQueryStatsScope.fromContext(context) - .ifPresent(stats -> stats.setSyncMode(SyncQueryStats.SyncMode.DELTA)); - logger.info( - String.format( - "Starting partial query update; upstream rev=%s; snapshot path=%s", - vcsState.map(s -> s.upstreamRevision).orElse(""), - vcsState.flatMap(s -> s.workspaceSnapshotPath).map(Object::toString).orElse(""))); - + Optional vcsState = Optional.empty(); + if (BlazeUserSettings.getInstance().getExpandSyncToWorkingSet()) { + vcsState = getVcsState(context); + SyncQueryStatsScope.fromContext(context) + .ifPresent(stats -> stats.setSyncMode(SyncQueryStats.SyncMode.DELTA)); + logger.info( + String.format( + "Starting partial query update; upstream rev=%s; snapshot path=%s", + vcsState.map(s -> s.upstreamRevision).orElse(""), + vcsState.flatMap(s -> s.workspaceSnapshotPath).map(Object::toString).orElse(""))); + } RefreshOperation refresh = projectRefresher.startPartialRefresh( context, diff --git a/base/src/com/google/idea/blaze/base/sync/ProjectStateSyncTask.java b/base/src/com/google/idea/blaze/base/sync/ProjectStateSyncTask.java index 8696f18bfd2..9afaa93f087 100644 --- a/base/src/com/google/idea/blaze/base/sync/ProjectStateSyncTask.java +++ b/base/src/com/google/idea/blaze/base/sync/ProjectStateSyncTask.java @@ -48,6 +48,7 @@ import com.google.idea.blaze.base.settings.Blaze; import com.google.idea.blaze.base.settings.BlazeImportSettings; import com.google.idea.blaze.base.settings.BlazeImportSettingsManager; +import com.google.idea.blaze.base.settings.BlazeUserSettings; import com.google.idea.blaze.base.sync.SyncScope.SyncCanceledException; import com.google.idea.blaze.base.sync.SyncScope.SyncFailedException; import com.google.idea.blaze.base.sync.projectview.LanguageSupport; @@ -125,7 +126,7 @@ private SyncProjectState getProjectState(BlazeContext context, BlazeSyncParams p createBazelInfoFuture(context, syncFlags, params.syncMode()); ListenableFuture workingSetFuture; - if (params.addWorkingSet() || params.syncMode() == SyncMode.FULL) { + if (params.addWorkingSet() || (BlazeUserSettings.getInstance().getExpandSyncToWorkingSet() && params.syncMode() == SyncMode.FULL)) { workingSetFuture = vcsHandler.getWorkingSet(context, executor); } else { workingSetFuture = Futures.immediateFuture(null);