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();
}
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());
}
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());
}
}
});
}
}
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);
}
Aggregations