use of org.zmlx.hg4idea.provider.annotate.HgAnnotationLine 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.provider.annotate.HgAnnotationLine in project intellij-community by JetBrains.
the class HgAnnotateCommandTest method loadEthalonAnnotations.
@BeforeClass
private void loadEthalonAnnotations() throws IOException {
myPluginRoot = new File(PluginPathManager.getPluginHomePath(HgVcs.VCS_NAME));
myAnnotateDataDir = new File(myPluginRoot, "testData/annotate");
myOutputsDir = new File(myAnnotateDataDir, "outputs");
final File etalonFile = new File(myAnnotateDataDir, "etalon");
XStream xStream = new XStream();
FileReader reader = new FileReader(etalonFile);
try {
myAnnotations = (List<HgAnnotationLine>) xStream.fromXML(reader);
} finally {
reader.close();
}
}
use of org.zmlx.hg4idea.provider.annotate.HgAnnotationLine in project intellij-community by JetBrains.
the class HgAnnotateCommandTest method generateCorrectAnnotation.
//@Test
public void generateCorrectAnnotation() throws IOException {
final File etalonFile = new File(myAnnotateDataDir, "etalon");
File outputFile = new File(myOutputsDir, "hg_1.9.0");
String output = FileUtil.loadFile(outputFile);
String[] split = output.split("(\n|\r|\r\n)");
List<HgAnnotationLine> annotationLines = new ArrayList<>(split.length);
Pattern pattern = Pattern.compile("\\s*(.+)\\s+(\\d+)\\s+([a-fA-F0-9]+)\\s+(\\d{4}-\\d{2}-\\d{2}):\\s*(\\d+): ?(.*)");
for (String line : split) {
Matcher matcher = pattern.matcher(line);
if (!matcher.matches()) {
fail("Couldn't parse line [ " + line + " ]");
}
String user = matcher.group(1);
String shortRev = matcher.group(2);
String fullRev = matcher.group(3);
String date = matcher.group(4);
String lineNum = matcher.group(5);
String content = matcher.group(6);
annotationLines.add(new HgAnnotationLine(user, HgRevisionNumber.getInstance(shortRev, fullRev), date, Integer.parseInt(lineNum), content));
}
XStream xStream = new XStream();
FileWriter writer = new FileWriter(etalonFile);
try {
xStream.toXML(annotationLines, writer);
} finally {
writer.close();
}
}
use of org.zmlx.hg4idea.provider.annotate.HgAnnotationLine in project intellij-community by JetBrains.
the class HgAnnotateCommand method parse.
private static List<HgAnnotationLine> parse(List<String> outputLines) {
List<HgAnnotationLine> annotations = new ArrayList<>(outputLines.size());
for (String line : outputLines) {
Matcher matcher = LINE_PATTERN.matcher(line);
if (matcher.matches()) {
String user = matcher.group(USER_GROUP).trim();
HgRevisionNumber rev = HgRevisionNumber.getInstance(matcher.group(REVISION_GROUP), matcher.group(CHANGESET_GROUP));
String dateGroup = matcher.group(DATE_GROUP).trim();
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy", Locale.US);
String date = "";
try {
date = DateFormatUtil.formatPrettyDate(dateFormat.parse(dateGroup));
} catch (ParseException e) {
LOG.error("Couldn't parse annotation date ", e);
}
Integer lineNumber = Integer.valueOf(matcher.group(LINE_NUMBER_GROUP));
String content = matcher.group(CONTENT_GROUP);
HgAnnotationLine annotationLine = new HgAnnotationLine(user, rev, date, lineNumber, content);
annotations.add(annotationLine);
}
}
return annotations;
}
use of org.zmlx.hg4idea.provider.annotate.HgAnnotationLine 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));
}
Aggregations