use of org.apache.maven.scm.command.blame.BlameLine in project maven-scm by apache.
the class SvnBlameConsumer method consumeLine.
public void consumeLine(String line) {
Matcher matcher;
if ((matcher = LINE_PATTERN.matcher(line)).find()) {
String lineNumberStr = matcher.group(1);
lineNumber = Integer.parseInt(lineNumberStr);
} else if ((matcher = REVISION_PATTERN.matcher(line)).find()) {
revision = matcher.group(1);
} else if ((matcher = AUTHOR_PATTERN.matcher(line)).find()) {
author = matcher.group(1);
} else if ((matcher = DATE_PATTERN.matcher(line)).find()) {
String date = matcher.group(1);
String time = matcher.group(2);
Date dateTime = parseDateTime(date + " " + time);
lines.add(new BlameLine(dateTime, revision, author));
if (getLogger().isDebugEnabled()) {
getLogger().debug("Author of line " + lineNumber + ": " + author + " (" + date + ")");
}
}
}
use of org.apache.maven.scm.command.blame.BlameLine in project maven-scm by apache.
the class PerforceBlameCommand method executeBlameCommand.
public BlameScmResult executeBlameCommand(ScmProviderRepository repo, ScmFileSet workingDirectory, String filename) throws ScmException {
// Call annotate command
PerforceScmProviderRepository p4repo = (PerforceScmProviderRepository) repo;
String clientspec = PerforceScmProvider.getClientspecName(getLogger(), p4repo, workingDirectory.getBasedir());
Commandline cl = createCommandLine((PerforceScmProviderRepository) repo, workingDirectory.getBasedir(), filename, clientspec);
PerforceBlameConsumer blameConsumer = new PerforceBlameConsumer(getLogger());
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
int exitCode;
try {
exitCode = CommandLineUtils.executeCommandLine(cl, blameConsumer, stderr);
} catch (CommandLineException ex) {
throw new ScmException("Error while executing command.", ex);
}
if (exitCode != 0) {
return new BlameScmResult(cl.toString(), "The perforce command failed.", stderr.getOutput(), false);
}
// Call filelog command
cl = createFilelogCommandLine((PerforceScmProviderRepository) repo, workingDirectory.getBasedir(), filename, clientspec);
PerforceFilelogConsumer filelogConsumer = new PerforceFilelogConsumer(getLogger());
try {
exitCode = CommandLineUtils.executeCommandLine(cl, filelogConsumer, stderr);
} catch (CommandLineException ex) {
throw new ScmException("Error while executing command.", ex);
}
if (exitCode != 0) {
return new BlameScmResult(cl.toString(), "The perforce command failed.", stderr.getOutput(), false);
}
// Combine results
List<BlameLine> lines = blameConsumer.getLines();
for (int i = 0; i < lines.size(); i++) {
BlameLine line = lines.get(i);
String revision = line.getRevision();
line.setAuthor(filelogConsumer.getAuthor(revision));
line.setDate(filelogConsumer.getDate(revision));
}
return new BlameScmResult(cl.toString(), lines);
}
use of org.apache.maven.scm.command.blame.BlameLine in project maven-scm by apache.
the class BazaarBlameCommandTckTest method verifyResult.
protected void verifyResult(BlameScmResult result) {
List<BlameLine> lines = result.getLines();
assertEquals("Expected 1 line in blame", 1, lines.size());
BlameLine line = lines.get(0);
assertEquals("1", line.getRevision());
}
use of org.apache.maven.scm.command.blame.BlameLine in project maven-scm by apache.
the class AnnotateConsumerTest method testParse.
@Test
public void testParse() throws Exception {
List<BlameLine> consumedLines = new ArrayList<BlameLine>();
AnnotateConsumer consumer = new AnnotateConsumer(consumedLines, new DefaultLog());
AccuRevJUnitUtil.consume("/annotate.txt", consumer);
Assert.assertEquals(12, consumer.getLines().size());
BlameLine line1 = (BlameLine) consumer.getLines().get(0);
Assert.assertEquals("2", line1.getRevision());
Assert.assertEquals("godin", line1.getAuthor());
assertThat(line1.getDate(), is(AccuRev.ACCUREV_TIME_SPEC.parse("2008/10/26 16:26:44")));
BlameLine line12 = (BlameLine) consumer.getLines().get(11);
Assert.assertEquals("1", line12.getRevision());
Assert.assertEquals("godin", line12.getAuthor());
assertThat(line12.getDate(), is(AccuRev.ACCUREV_TIME_SPEC.parse("2008/10/17 11:41:50")));
}
use of org.apache.maven.scm.command.blame.BlameLine in project maven-scm by apache.
the class AnnotateConsumer method consumeLine.
public void consumeLine(String line) {
final Matcher matcher = LINE_PATTERN.matcher(line);
if (matcher.matches()) {
String revision = matcher.group(1).trim();
String author = matcher.group(2).trim();
String dateStr = matcher.group(3).trim();
Date date = parseDate(dateStr, null, AccuRev.ACCUREV_TIME_FORMAT_STRING);
lines.add(new BlameLine(date, revision, author));
} else {
throw new RuntimeException("Unable to parse annotation from line: " + line);
}
}
Aggregations