public void test_support_equally_named_branch_and_tag() throws Exception {
    prepareSomeHistory();
    git("branch build");
    git("tag build");

    VcsLogProvider.DetailedLogData data =
        myLogProvider.readFirstBlock(
            myProjectRoot, new RequirementsImpl(1000, true, Collections.<VcsRef>emptySet()));
    List<VcsCommitMetadata> expectedLog = log();
    assertOrderedEquals(data.getCommits(), expectedLog);
    assertTrue(
        ContainerUtil.exists(
            data.getRefs(),
            new Condition<VcsRef>() {
              @Override
              public boolean value(VcsRef ref) {
                return ref.getName().equals("build") && ref.getType() == GitRefManager.LOCAL_BRANCH;
              }
            }));
    assertTrue(
        ContainerUtil.exists(
            data.getRefs(),
            new Condition<VcsRef>() {
              @Override
              public boolean value(VcsRef ref) {
                return ref.getName().equals("build") && ref.getType() == GitRefManager.TAG;
              }
            }));
  }
  private boolean processFilesConcurrently(
      @NotNull Set<VirtualFile> files,
      @NotNull final ProgressIndicator indicator,
      @NotNull final Processor<VirtualFile> processor) {
    final List<VirtualFile> fileList = new ArrayList<VirtualFile>(files);
    // fine but grabs all CPUs
    // return JobLauncher.getInstance().invokeConcurrentlyUnderProgress(fileList, indicator, false,
    // false, processor);

    int parallelism = CacheUpdateRunner.indexingThreadCount();
    final Callable<Boolean> processFileFromSet =
        () -> {
          final boolean[] result = {true};
          ProgressManager.getInstance()
              .executeProcessUnderProgress(
                  () -> {
                    while (true) {
                      ProgressManager.checkCanceled();
                      VirtualFile file;
                      synchronized (fileList) {
                        file = fileList.isEmpty() ? null : fileList.remove(fileList.size() - 1);
                      }
                      if (file == null) {
                        break;
                      }
                      if (!processor.process(file)) {
                        result[0] = false;
                        break;
                      }
                    }
                  },
                  indicator);
          return result[0];
        };
    List<Future<Boolean>> futures =
        ContainerUtil.map(
            Collections.nCopies(parallelism, ""),
            s -> myApplication.executeOnPooledThread(processFileFromSet));

    List<Boolean> results =
        ContainerUtil.map(
            futures,
            future -> {
              try {
                return future.get();
              } catch (Exception e) {
                LOG.error(e);
              }
              return false;
            });

    return !ContainerUtil.exists(
        results,
        result -> {
          return result != null && !result; // null means PCE
        });
  }
  public void test_dont_report_origin_HEAD() throws Exception {
    prepareSomeHistory();
    git("update-ref refs/remotes/origin/HEAD master");

    VcsLogProvider.DetailedLogData block =
        myLogProvider.readFirstBlock(
            myProjectRoot, new RequirementsImpl(1000, false, Collections.<VcsRef>emptySet()));
    assertFalse(
        "origin/HEAD should be ignored",
        ContainerUtil.exists(
            block.getRefs(),
            new Condition<VcsRef>() {
              @Override
              public boolean value(VcsRef ref) {
                return ref.getName().equals("origin/HEAD");
              }
            }));
  }
 private static void suggestRollback(
     @NotNull Project project,
     @NotNull Collection<PatchApplier> group,
     @NotNull Label beforeLabel) {
   Collection<FilePatch> allFailed =
       ContainerUtil.concat(
           group,
           new Function<PatchApplier, Collection<? extends FilePatch>>() {
             @Override
             public Collection<FilePatch> fun(PatchApplier applier) {
               return applier.getFailedPatches();
             }
           });
   boolean shouldInformAboutBinaries =
       ContainerUtil.exists(
           group,
           new Condition<PatchApplier>() {
             @Override
             public boolean value(PatchApplier applier) {
               return !applier.getBinaryPatches().isEmpty();
             }
           });
   final UndoApplyPatchDialog undoApplyPatchDialog =
       new UndoApplyPatchDialog(
           project,
           ContainerUtil.map(
               allFailed,
               new Function<FilePatch, FilePath>() {
                 @Override
                 public FilePath fun(FilePatch filePatch) {
                   String path =
                       filePatch.getAfterName() == null
                           ? filePatch.getBeforeName()
                           : filePatch.getAfterName();
                   return VcsUtil.getFilePath(path);
                 }
               }),
           shouldInformAboutBinaries);
   undoApplyPatchDialog.show();
   if (undoApplyPatchDialog.isOK()) {
     rollbackUnderProgress(project, project.getBaseDir(), beforeLabel);
   }
 }
  private static List<LanguageDefinition> collectProjectLanguages(
      final Collection<PsiClass> projectLanguages,
      final List<LanguageDefinition> libraryLanguages) {
    return ContainerUtil.mapNotNull(
        projectLanguages,
        (NullableFunction<PsiClass, LanguageDefinition>)
            language -> {
              if (language.hasModifierProperty(PsiModifier.ABSTRACT)) {
                return null;
              }

              if (ContainerUtil.exists(
                  libraryLanguages, definition -> definition.clazz.equals(language))) {
                return null;
              }

              return CachedValuesManager.getCachedValue(
                  language,
                  () -> {
                    String languageId = computeConstantSuperCtorCallParameter(language, 0);
                    if (languageId == null) {
                      languageId = computeConstantSuperCtorCallParameter(language, 1);
                    }
                    if (languageId == null) {
                      languageId = computeConstantReturnValue(language, "getID");
                    }
                    if (StringUtil.isEmpty(languageId)) {
                      return Result.create((LanguageDefinition) null, language);
                    }

                    String displayName = computeConstantReturnValue(language, "getDisplayName");

                    return Result.createSingleDependency(
                        new LanguageDefinition(languageId, language, null, displayName), language);
                  });
            });
  }
  public void testSaveContextOnCommit() throws Exception {
    myTaskManager.getState().saveContextOnCommit = true;

    assertEquals(1, myTaskManager.getLocalTasks().size());
    assertEquals(1, myChangeListManager.getChangeListsCopy().size());

    LocalChangeList changeList = addChangeList("New Changelist", "");

    assertEquals(1, myTaskManager.getLocalTasks().size());
    assertEquals(2, myChangeListManager.getChangeListsCopy().size());

    CommitChangeListDialog.commitChanges(
        getProject(), Collections.<Change>emptyList(), changeList, null, changeList.getName());

    assertEquals(2, myTaskManager.getLocalTasks().size()); // extra task created
    assertEquals(2, myChangeListManager.getChangeListsCopy().size());

    assertTrue(
        ContainerUtil.exists(
            myTaskManager.getLocalTasks(),
            task -> {
              return task.getSummary().equals("New Changelist");
            }));
  }