use of org.zmlx.hg4idea.command.HgLogCommand 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.HgLogCommand in project intellij-community by JetBrains.
the class HgHistoryTest method testFileNameInTargetRevisionAfterRename.
public void testFileNameInTargetRevisionAfterRename() throws HgCommandException {
cd(myRepository);
int namesSize = names.length;
VirtualFile subDir = myRepository.findFileByRelativePath(subDirName);
assert subDir != null;
VirtualFile vFile = VfsUtil.findFileByIoFile(new File(subDir.getPath(), names[namesSize - 1]), true);
assert vFile != null;
HgFile hgFile = new HgFile(myRepository, VfsUtilCore.virtualToIoFile(vFile));
HgLogCommand logCommand = new HgLogCommand(myProject);
logCommand.setFollowCopies(true);
List<HgFileRevision> revisions = logCommand.execute(hgFile, -1, true);
for (int i = 0; i < revisions.size(); ++i) {
HgFile expectedFile = new HgFile(myRepository, new File(subDir.getPath(), names[namesSize - i - 1]));
HgFile targetFileName = HgUtil.getFileNameInTargetRevision(myProject, revisions.get(i).getRevisionNumber(), hgFile);
assertEquals(expectedFile.getRelativePath(), targetFileName.getRelativePath());
}
}
use of org.zmlx.hg4idea.command.HgLogCommand in project intellij-community by JetBrains.
the class HgHistoryTest method testFileNameInTargetRevisionAfterUpdate.
public void testFileNameInTargetRevisionAfterUpdate() throws HgCommandException {
cd(myRepository);
//update to parent revision
hg("update -r .^");
//update filenames size which is in use
int namesSize = names.length - 1;
//find file with parent revision name
VirtualFile subDir = myRepository.findFileByRelativePath(subDirName);
assert subDir != null;
VirtualFile vFile = VfsUtil.findFileByIoFile(new File(subDir.getPath(), names[namesSize - 1]), true);
assert vFile != null;
HgFile hgFile = new HgFile(myRepository, VfsUtilCore.virtualToIoFile(vFile));
HgLogCommand logCommand = new HgLogCommand(myProject);
logCommand.setFollowCopies(true);
List<HgFileRevision> revisions = logCommand.execute(hgFile, -1, true);
for (int i = 0; i < revisions.size(); ++i) {
HgFile expectedFile = new HgFile(myRepository, new File(subDir.getPath(), names[namesSize - i - 1]));
HgFile targetFileName = HgUtil.getFileNameInTargetRevision(myProject, revisions.get(i).getRevisionNumber(), hgFile);
assertEquals(expectedFile.getRelativePath(), targetFileName.getRelativePath());
}
}
use of org.zmlx.hg4idea.command.HgLogCommand in project intellij-community by JetBrains.
the class HgHistoryTest method testFileNameInTargetRevisionFromAffectedFiles.
public void testFileNameInTargetRevisionFromAffectedFiles() throws HgCommandException {
cd(myRepository);
int namesSize = names.length;
VirtualFile subDir = myRepository.findFileByRelativePath(subDirName);
assert subDir != null;
VirtualFile vFile = VfsUtil.findFileByIoFile(new File(subDir.getPath(), names[namesSize - 1]), true);
assert vFile != null;
HgFile localFile = new HgFile(myRepository, VfsUtilCore.virtualToIoFile(vFile));
HgLogCommand logCommand = new HgLogCommand(myProject);
logCommand.setFollowCopies(true);
List<HgFileRevision> revisions = logCommand.execute(localFile, -1, true);
for (int i = 0; i < namesSize; ++i) {
HgFile hgFile = new HgFile(myRepository, new File(subDir.getPath(), names[namesSize - i - 1]));
HgFile targetFileName = HgUtil.getFileNameInTargetRevision(myProject, revisions.get(i).getRevisionNumber(), hgFile);
assertEquals(hgFile.getRelativePath(), targetFileName.getRelativePath());
}
}
use of org.zmlx.hg4idea.command.HgLogCommand in project intellij-community by JetBrains.
the class HgLogTest method parseCopied.
private void parseCopied(@NotNull String sourceFileName) throws HgCommandException {
cd(myRepository);
String copiedFileName = "copy".concat(sourceFileName);
touch(sourceFileName);
myRepository.refresh(false, true);
hg("add " + sourceFileName);
hg("commit -m a ");
hg("cp " + sourceFileName + " " + copiedFileName);
myRepository.refresh(false, true);
hg("commit -m a ");
HgLogCommand logCommand = new HgLogCommand(myProject);
logCommand.setFollowCopies(false);
VirtualFile copiedFile = myRepository.findChild(copiedFileName);
assert copiedFile != null;
final HgFile hgFile = new HgFile(myRepository, VfsUtilCore.virtualToIoFile(copiedFile));
List<HgFileRevision> revisions = logCommand.execute(hgFile, 1, true);
HgFileRevision rev = revisions.get(0);
assertTrue(!rev.getAddedFiles().isEmpty());
}
Aggregations