AccessToken (@NotNull GitLineHandler handler, boolean canSuppressOptionalLocks) { Project project = handler.project(); LockingPolicy lockingPolicy = handler.getCommand().lockingPolicy(); if (project == null || project.isDefault() || lockingPolicy == READ) { return AccessToken.EMPTY_ACCESS_TOKEN; } ReadWriteLock executionLock = GitVcs.getInstance(project).getCommandLock(); Lock lock = lockingPolicy == READ_OPTIONAL_LOCKING && canSuppressOptionalLocks ? executionLock.readLock() : executionLock.writeLock(); ProgressIndicatorUtils.awaitWithCheckCanceled(lock); return new AccessToken() { @Override public void finish() { lock.unlock(); } }; }