use of org.zmlx.hg4idea.command.HgAnnotateCommand in project intellij-community by JetBrains.
the class HgAnnotationTest method testAnnotationWithVerboseOption.
public void testAnnotationWithVerboseOption() throws VcsException {
myRepository.refresh(false, true);
final VirtualFile file = myRepository.findFileByRelativePath(firstCreatedFile);
assert file != null;
List<String> users = Arrays.asList(defaultAuthor, author1, author2);
final HgFile hgFile = new HgFile(myRepository, VfsUtilCore.virtualToIoFile(file));
final String date = DateFormatUtil.formatPrettyDate(Clock.getTime());
List<HgAnnotationLine> annotationLines = new HgAnnotateCommand(myProject).execute(hgFile, null);
for (int i = 0; i < annotationLines.size(); ++i) {
HgAnnotationLine line = annotationLines.get(i);
assertEquals(users.get(i), line.get(HgAnnotation.FIELD.USER));
assertEquals(date, line.get(HgAnnotation.FIELD.DATE));
}
}
use of org.zmlx.hg4idea.command.HgAnnotateCommand in project intellij-community by JetBrains.
the class HgAnnotationProvider method annotate.
@NotNull
public FileAnnotation annotate(@NotNull VirtualFile file, VcsFileRevision revision) throws VcsException {
final VirtualFile vcsRoot = VcsUtil.getVcsRootFor(myProject, VcsUtil.getFilePath(file.getPath()));
if (vcsRoot == null) {
throw new VcsException("vcs root is null for " + file);
}
HgRevisionNumber revisionNumber = revision != null ? (HgRevisionNumber) revision.getRevisionNumber() : null;
final HgFile hgFile = new HgFile(vcsRoot, VfsUtilCore.virtualToIoFile(file));
HgFile fileToAnnotate = revision instanceof HgFileRevision ? HgUtil.getFileNameInTargetRevision(myProject, revisionNumber, hgFile) : new HgFile(vcsRoot, HgUtil.getOriginalFileName(hgFile.toFilePath(), ChangeListManager.getInstance(myProject)));
final List<HgAnnotationLine> annotationResult = (new HgAnnotateCommand(myProject)).execute(fileToAnnotate, revisionNumber);
//for uncommitted renamed file we should provide local name otherwise --follow will fail
final List<HgFileRevision> logResult = HgHistoryProvider.getHistory(revision == null ? hgFile.toFilePath() : fileToAnnotate.toFilePath(), vcsRoot, myProject, null, -1);
return new HgAnnotation(myProject, hgFile, annotationResult, logResult, revisionNumber != null ? revisionNumber : new HgWorkingCopyRevisionsCommand(myProject).tip(vcsRoot));
}
use of org.zmlx.hg4idea.command.HgAnnotateCommand in project intellij-community by JetBrains.
the class HgAnnotationProvider method annotate.
@NotNull
@Override
public FileAnnotation annotate(@NotNull FilePath path, @NotNull VcsRevisionNumber revision) throws VcsException {
final VirtualFile vcsRoot = VcsUtil.getVcsRootFor(myProject, path);
if (vcsRoot == null) {
throw new VcsException("vcs root is null for " + path);
}
final HgFile hgFile = new HgFile(vcsRoot, path);
final List<HgAnnotationLine> annotationResult = (new HgAnnotateCommand(myProject)).execute(hgFile, (HgRevisionNumber) revision);
final List<HgFileRevision> logResult = HgHistoryProvider.getHistory(hgFile.toFilePath(), vcsRoot, myProject, (HgRevisionNumber) revision, -1);
return new HgAnnotation(myProject, hgFile, annotationResult, logResult, revision);
}
use of org.zmlx.hg4idea.command.HgAnnotateCommand in project intellij-community by JetBrains.
the class HgAnnotationTest method annotationWithWhitespaceOption.
private void annotationWithWhitespaceOption(boolean ignoreWhitespaces) {
cd(myRepository);
String whitespaceFile = "whitespaces.txt";
touch(whitespaceFile, "not whitespaces");
myRepository.refresh(false, true);
String whiteSpaceAuthor = "Mr.Whitespace";
final VirtualFile file = myRepository.findFileByRelativePath(whitespaceFile);
assert file != null;
hg("add " + whitespaceFile);
hg("commit -m modify -u '" + defaultAuthor + "'");
//add several whitespaces
echo(whitespaceFile, " ");
hg("commit -m whitespaces -u '" + whiteSpaceAuthor + "'");
final HgFile hgFile = new HgFile(myRepository, VfsUtilCore.virtualToIoFile(file));
myVcs.getProjectSettings().setIgnoreWhitespacesInAnnotations(ignoreWhitespaces);
List<HgAnnotationLine> annotationLines = new HgAnnotateCommand(myProject).execute(hgFile, null);
HgAnnotationLine line = annotationLines.get(0);
assertEquals(ignoreWhitespaces ? defaultAuthor : whiteSpaceAuthor, line.get(HgAnnotation.FIELD.USER));
}
use of org.zmlx.hg4idea.command.HgAnnotateCommand in project intellij-community by JetBrains.
the class HgAnnotateCommandTest method testParse.
@Test(dataProvider = "annotate_output")
public void testParse(String fileName, String annotationNativeOutput) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
HgAnnotateCommand command = new HgAnnotateCommand(myProject);
Method parseMethod = HgAnnotateCommand.class.getDeclaredMethod("parse", List.class);
parseMethod.setAccessible(true);
List<String> annotations = Arrays.asList(annotationNativeOutput.split("(\n|\r|\r\n)"));
List<HgAnnotationLine> result = (List<HgAnnotationLine>) parseMethod.invoke(command, annotations);
assertEquals(result, myAnnotations);
}
Aggregations