Search in sources :

Example 1 with HgCommitCommand

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

the class HgEncodingTest method testCommitUtfMessage.

//test for  default EncodingProject settings
public void testCommitUtfMessage() throws HgCommandException, VcsException {
    cd(myRepository);
    echo("file.txt", "lalala");
    HgRepository hgRepo = HgRepositoryImpl.getInstance(myRepository, myProject, myProject);
    HgCommitCommand commitCommand = new HgCommitCommand(myProject, hgRepo, "сообщение");
    commitCommand.executeInCurrentThread();
}
Also used : HgCommitCommand(org.zmlx.hg4idea.command.HgCommitCommand) HgRepository(org.zmlx.hg4idea.repo.HgRepository)

Example 2 with HgCommitCommand

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

the class HgEncodingTest method testUtfMessageInHistoryWithSpecialCharacters.

//test SpecialCharacters in commit message for default EncodingProject settings
public void testUtfMessageInHistoryWithSpecialCharacters() throws HgCommandException, VcsException {
    cd(myRepository);
    String fileName = "file.txt";
    echo(fileName, "lalala");
    Charset charset = HgEncodingUtil.getDefaultCharset(myProject);
    String comment = "öäüß";
    HgRepository hgRepo = HgRepositoryImpl.getInstance(myRepository, myProject, myProject);
    HgCommitCommand commitCommand = new HgCommitCommand(myProject, hgRepo, comment);
    commitCommand.executeInCurrentThread();
    HgLogCommand logCommand = new HgLogCommand(myProject);
    myRepository.refresh(false, true);
    VirtualFile file = myRepository.findChild(fileName);
    assert file != null;
    List<HgFileRevision> revisions = logCommand.execute(new HgFile(myProject, file), 1, false);
    HgFileRevision rev = revisions.get(0);
    assertEquals(new String(comment.getBytes(charset)), rev.getCommitMessage());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) HgFile(org.zmlx.hg4idea.HgFile) HgCommitCommand(org.zmlx.hg4idea.command.HgCommitCommand) HgFileRevision(org.zmlx.hg4idea.HgFileRevision) Charset(java.nio.charset.Charset) HgRepository(org.zmlx.hg4idea.repo.HgRepository) HgLogCommand(org.zmlx.hg4idea.command.HgLogCommand)

Example 3 with HgCommitCommand

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

the class HgTaskHandler method mergeAndClose.

@Override
protected void mergeAndClose(@NotNull final String branch, @NotNull final List<HgRepository> repositories) {
    String bookmarkRevisionArg = "bookmark(\"" + branch + "\")";
    FileDocumentManager.getInstance().saveAllDocuments();
    final UpdatedFiles updatedFiles = UpdatedFiles.create();
    for (final HgRepository repository : repositories) {
        HgMergeCommand.mergeWith(repository, bookmarkRevisionArg, updatedFiles, new Runnable() {

            @Override
            public void run() {
                Project project = repository.getProject();
                VirtualFile repositoryRoot = repository.getRoot();
                try {
                    new HgCommitCommand(project, repository, "Automated merge with " + branch).executeInCurrentThread();
                    HgBookmarkCommand.deleteBookmarkSynchronously(project, repositoryRoot, branch);
                } catch (HgCommandException e) {
                    HgErrorUtil.handleException(project, e);
                } catch (VcsException e) {
                    VcsNotifier.getInstance(project).notifyError("Exception during merge commit with " + branch, e.getMessage());
                }
            }
        });
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) HgCommitCommand(org.zmlx.hg4idea.command.HgCommitCommand) VcsException(com.intellij.openapi.vcs.VcsException) UpdatedFiles(com.intellij.openapi.vcs.update.UpdatedFiles) HgRepository(org.zmlx.hg4idea.repo.HgRepository) HgCommandException(org.zmlx.hg4idea.execution.HgCommandException)

Example 4 with HgCommitCommand

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

the class HgCommitTest method testAmendCommit.

public void testAmendCommit() throws HgCommandException, VcsException {
    String changedCommit = "anotherCommit";
    HgLogCommand logCommand = new HgLogCommand(myProject);
    logCommand.setLogFile(false);
    HgFile hgFile = new HgFile(myRepository, VfsUtilCore.virtualToIoFile(myRepository));
    List<HgFileRevision> revisions = logCommand.execute(hgFile, -1, false);
    HgRepository hgRepo = HgRepositoryImpl.getInstance(myRepository, myProject, myProject);
    HgCommitCommand commit = new HgCommitCommand(myProject, hgRepo, changedCommit, true);
    commit.executeInCurrentThread();
    List<HgFileRevision> revisionsAfterAmendCommit = logCommand.execute(hgFile, -1, false);
    assertTrue(revisions.size() == revisionsAfterAmendCommit.size());
    assertEquals(revisionsAfterAmendCommit.get(0).getCommitMessage(), changedCommit);
}
Also used : HgFile(org.zmlx.hg4idea.HgFile) HgCommitCommand(org.zmlx.hg4idea.command.HgCommitCommand) HgFileRevision(org.zmlx.hg4idea.HgFileRevision) HgRepository(org.zmlx.hg4idea.repo.HgRepository) HgLogCommand(org.zmlx.hg4idea.command.HgLogCommand)

Aggregations

HgCommitCommand (org.zmlx.hg4idea.command.HgCommitCommand)4 HgRepository (org.zmlx.hg4idea.repo.HgRepository)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 HgFile (org.zmlx.hg4idea.HgFile)2 HgFileRevision (org.zmlx.hg4idea.HgFileRevision)2 HgLogCommand (org.zmlx.hg4idea.command.HgLogCommand)2 Project (com.intellij.openapi.project.Project)1 VcsException (com.intellij.openapi.vcs.VcsException)1 UpdatedFiles (com.intellij.openapi.vcs.update.UpdatedFiles)1 Charset (java.nio.charset.Charset)1 HgCommandException (org.zmlx.hg4idea.execution.HgCommandException)1