コード例 #1
0
  @Test
  public void updateShouldNotMergeIfMultipleHeadsBeforeUpdate() throws Exception {
    changeFile_A_AndCommitInRemoteRepository();
    createAndCommitNewFileInLocalRepository();

    // create multiple heads locally
    HgUpdateCommand updateCommand = new HgUpdateCommand(myProject, projectRepoVirtualFile);
    HgRevisionNumber parent =
        new HgParentsCommand(myProject).execute(projectRepoVirtualFile).get(0);
    HgParentsCommand parentsCommand = new HgParentsCommand(myProject);
    parentsCommand.setRevision(parent);
    List<HgRevisionNumber> parents = parentsCommand.execute(projectRepoVirtualFile);
    updateCommand.setRevision(parents.get(0).getChangeset());
    updateCommand.execute();

    createFileInCommand(projectRepoVirtualFile.findChild("com"), "c.txt", "updated content");
    runHg(projectRepo, "commit", "-m", "creating new local head");

    List<HgRevisionNumber> branchHeads =
        new HgHeadsCommand(myProject, projectRepoVirtualFile).execute();
    assertEquals(branchHeads.size(), 2);

    HgRevisionNumber parentBeforeUpdate =
        new HgWorkingCopyRevisionsCommand(myProject).identify(projectRepoVirtualFile).getFirst();
    assertUpdateThroughPluginFails();
    HgRevisionNumber parentAfterUpdate =
        new HgWorkingCopyRevisionsCommand(myProject).identify(projectRepoVirtualFile).getFirst();
    List<HgRevisionNumber> branchHeadsAfterUpdate =
        new HgHeadsCommand(myProject, projectRepoVirtualFile).execute();

    assertEquals(branchHeadsAfterUpdate.size(), 3);
    assertEquals(parentBeforeUpdate, parentAfterUpdate);
  }
コード例 #2
0
  private void updateToPulledHead(
      VirtualFile repo,
      UpdatedFiles updatedFiles,
      HgRevisionNumber newHead,
      ProgressIndicator indicator) {
    indicator.setText2(HgVcsMessages.message("hg4idea.update.progress.updating.to.pulled.head"));
    HgRevisionNumber parentBeforeUpdate =
        new HgWorkingCopyRevisionsCommand(project).firstParent(repo);
    HgUpdateCommand updateCommand = new HgUpdateCommand(project, repoRoot);
    updateCommand.setRevision(newHead.getChangeset());
    updateCommand.setClean(true);
    updateCommand.execute();

    HgRevisionNumber commonParent = findCommonParent(newHead, parentBeforeUpdate);
    addUpdatedFiles(repo, updatedFiles, commonParent, newHead);
  }
コード例 #3
0
  private void update(
      @NotNull VirtualFile repo,
      ProgressIndicator indicator,
      UpdatedFiles updatedFiles,
      List<VcsException> warnings)
      throws VcsException {
    indicator.setText2(HgVcsMessages.message("hg4idea.progress.updatingworkingdir"));

    HgRevisionNumber parentBeforeUpdate =
        new HgWorkingCopyRevisionsCommand(project).firstParent(repo);
    HgUpdateCommand hgUpdateCommand = new HgUpdateCommand(project, repo);
    String warningMessages = ensureSuccess(hgUpdateCommand.execute()).getWarnings();
    handlePossibleWarning(warnings, warningMessages);

    HgRevisionNumber parentAfterUpdate =
        new HgWorkingCopyRevisionsCommand(project).firstParent(repo);

    addUpdatedFiles(repo, updatedFiles, parentBeforeUpdate, parentAfterUpdate);
  }