Search in sources :

Example 1 with HgQNewCommand

use of org.zmlx.hg4idea.command.mq.HgQNewCommand in project intellij-community by JetBrains.

the class MqPatchTest method testMqPatchInfoAfterQNew.

public void testMqPatchInfoAfterQNew() throws Exception {
    cd(myRepository);
    append(FILENAME, "modify");
    myRepository.refresh(false, true);
    new HgQNewCommand(myProject, myHgRepository, MESSAGE, false).executeInCurrentThread();
    myRepository.refresh(false, true);
    MqPatchDetails patchDetails = updateAndGetDetails();
    assertEqualsCommitInfo(null, patchDetails);
}
Also used : HgQNewCommand(org.zmlx.hg4idea.command.mq.HgQNewCommand) MqPatchDetails(org.zmlx.hg4idea.mq.MqPatchDetails)

Example 2 with HgQNewCommand

use of org.zmlx.hg4idea.command.mq.HgQNewCommand in project intellij-community by JetBrains.

the class HgCheckinEnvironment method commit.

public List<VcsException> commit(List<Change> changes, String preparedComment, @NotNull NullableFunction<Object, Object> parametersHolder, Set<String> feedback) {
    List<VcsException> exceptions = new LinkedList<>();
    Map<HgRepository, Set<HgFile>> repositoriesMap = getFilesByRepository(changes);
    addRepositoriesWithoutChanges(repositoriesMap);
    for (Map.Entry<HgRepository, Set<HgFile>> entry : repositoriesMap.entrySet()) {
        HgRepository repo = entry.getKey();
        Set<HgFile> selectedFiles = entry.getValue();
        HgCommitTypeCommand command = myMqNewPatch ? new HgQNewCommand(myProject, repo, preparedComment, myNextCommitAmend) : new HgCommitCommand(myProject, repo, preparedComment, myNextCommitAmend, myCloseBranch, myShouldCommitSubrepos && !selectedFiles.isEmpty());
        if (isMergeCommit(repo.getRoot())) {
            //partial commits are not allowed during merges
            //verifyResult that all changed files in the repo are selected
            //If so, commit the entire repository
            //If not, abort
            Set<HgFile> changedFilesNotInCommit = getChangedFilesNotInCommit(repo.getRoot(), selectedFiles);
            boolean partial = !changedFilesNotInCommit.isEmpty();
            if (partial) {
                final StringBuilder filesNotIncludedString = new StringBuilder();
                for (HgFile hgFile : changedFilesNotInCommit) {
                    filesNotIncludedString.append("<li>");
                    filesNotIncludedString.append(hgFile.getRelativePath());
                    filesNotIncludedString.append("</li>");
                }
                if (!mayCommitEverything(filesNotIncludedString.toString())) {
                    //abort
                    return exceptions;
                }
                //firstly selected changes marked dirty in CommitHelper -> postRefresh, so we need to mark others
                VcsDirtyScopeManager dirtyManager = VcsDirtyScopeManager.getInstance(myProject);
                for (HgFile hgFile : changedFilesNotInCommit) {
                    dirtyManager.fileDirty(hgFile.toFilePath());
                }
            }
        // else : all was included, or it was OK to commit everything,
        // so no need to set the files on the command, because then mercurial will complain
        } else {
            command.setFiles(selectedFiles);
        }
        try {
            command.executeInCurrentThread();
        } catch (HgCommandException e) {
            exceptions.add(new VcsException(e));
        } catch (VcsException e) {
            exceptions.add(e);
        }
    }
    // push if needed
    if (myNextCommitIsPushed && exceptions.isEmpty()) {
        final List<HgRepository> preselectedRepositories = ContainerUtil.newArrayList(repositoriesMap.keySet());
        GuiUtils.invokeLaterIfNeeded(() -> new VcsPushDialog(myProject, preselectedRepositories, HgUtil.getCurrentRepository(myProject)).show(), ModalityState.defaultModalityState());
    }
    return exceptions;
}
Also used : HgQNewCommand(org.zmlx.hg4idea.command.mq.HgQNewCommand) HgCommandException(org.zmlx.hg4idea.execution.HgCommandException) VcsPushDialog(com.intellij.dvcs.push.ui.VcsPushDialog) VcsException(com.intellij.openapi.vcs.VcsException) HgRepository(org.zmlx.hg4idea.repo.HgRepository)

Aggregations

HgQNewCommand (org.zmlx.hg4idea.command.mq.HgQNewCommand)2 VcsPushDialog (com.intellij.dvcs.push.ui.VcsPushDialog)1 VcsException (com.intellij.openapi.vcs.VcsException)1 HgCommandException (org.zmlx.hg4idea.execution.HgCommandException)1 MqPatchDetails (org.zmlx.hg4idea.mq.MqPatchDetails)1 HgRepository (org.zmlx.hg4idea.repo.HgRepository)1