use of org.apache.maven.scm.command.blame.BlameLine in project maven-scm by apache.
the class CvsBlameConsumer method consumeLine.
public void consumeLine(String line) {
if (line != null && line.indexOf(':') > 0) {
String annotation = line.substring(0, line.indexOf(':'));
Matcher matcher = LINE_PATTERN.matcher(annotation);
if (matcher.matches()) {
String revision = matcher.group(1).trim();
String author = matcher.group(2).trim();
String dateTimeStr = matcher.group(3).trim();
Date dateTime = parseDate(dateTimeStr, null, CVS_TIMESTAMP_PATTERN, Locale.US);
lines.add(new BlameLine(dateTime, revision, author));
if (getLogger().isDebugEnabled()) {
getLogger().debug(author + " " + dateTimeStr);
}
}
}
}
use of org.apache.maven.scm.command.blame.BlameLine in project maven-scm by apache.
the class BlameCommandTckTest method testBlameCommand.
public void testBlameCommand() throws Exception {
ScmRepository repository = getScmRepository();
ScmManager manager = getScmManager();
ScmProvider provider = manager.getProviderByRepository(getScmRepository());
ScmFileSet fileSet = new ScmFileSet(getWorkingCopy());
BlameScmResult result;
BlameLine line;
// === readme.txt ===
BlameScmRequest blameScmRequest = new BlameScmRequest(repository, fileSet);
blameScmRequest.setFilename("readme.txt");
// result = manager.blame( repository, fileSet, "readme.txt" );
result = manager.blame(blameScmRequest);
assertNotNull("The command returned a null result.", result);
assertResultIsSuccess(result);
assertEquals("Expected 1 line in blame", 1, result.getLines().size());
line = result.getLines().get(0);
String initialRevision = line.getRevision();
// Make a timestamp that we know are after initial revision but before the second
// Current time
Date timeBeforeSecond = new Date();
// pause a couple seconds...
Thread.sleep(2000);
// Make a change to the readme.txt and commit the change
this.edit(getWorkingCopy(), "readme.txt", null, getScmRepository());
ScmTestCase.makeFile(getWorkingCopy(), "/readme.txt", "changed readme.txt");
CheckInScmResult checkInResult = provider.checkIn(getScmRepository(), fileSet, COMMIT_MSG);
assertTrue("Unable to checkin changes to the repository", checkInResult.isSuccess());
result = manager.blame(repository, fileSet, "readme.txt");
// pause a couple seconds...
Thread.sleep(2000);
// Current time
Date timeAfterSecond = new Date();
assertNotNull("The command returned a null result.", result);
assertResultIsSuccess(result);
assertEquals("Expected 1 line in blame", 1, result.getLines().size());
line = result.getLines().get(0);
assertNotNull("Expected not null author", line.getAuthor());
assertNotNull("Expected not null revision", line.getRevision());
assertNotNull("Expected not null date", line.getDate());
assertTrue("Expected another revision", !initialRevision.equals(line.getRevision()));
if (isTestDateTime()) {
assertDateBetween(timeBeforeSecond, timeAfterSecond, line.getDate());
}
// === pom.xml ===
result = manager.blame(repository, fileSet, "pom.xml");
assertNotNull("The command returned a null result.", result);
assertResultIsSuccess(result);
verifyResult(result);
}
use of org.apache.maven.scm.command.blame.BlameLine in project maven-scm by apache.
the class AccuRevBlameCommand method executeAccurevCommand.
@Override
protected BlameScmResult executeAccurevCommand(AccuRevScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException, AccuRevException {
AccuRev accuRev = repository.getAccuRev();
File file = new File(parameters.getString(CommandParameter.FILE));
List<BlameLine> lines = accuRev.annotate(fileSet.getBasedir(), file);
if (lines != null) {
return new BlameScmResult(accuRev.getCommandLines(), lines);
} else {
return new BlameScmResult(accuRev.getCommandLines(), "AccuRev Error", accuRev.getErrorOutput(), false);
}
}
use of org.apache.maven.scm.command.blame.BlameLine in project maven-scm by apache.
the class PerforceBlameConsumer method consumeLine.
/**
* {@inheritDoc}
*/
public void consumeLine(String line) {
Matcher matcher = LINE_PATTERN.matcher(line);
if (matcher.find()) {
String revision = matcher.group(1).trim();
lines.add(new BlameLine(null, revision, null));
}
}
use of org.apache.maven.scm.command.blame.BlameLine in project maven-scm by apache.
the class PerforceBlameConsumerTest method testParse.
public void testParse() throws IOException {
File testFile = getTestFile("src/test/resources/perforce/annotatelog.txt");
PerforceBlameConsumer consumer = new PerforceBlameConsumer(new DefaultLog());
FileInputStream fis = new FileInputStream(testFile);
BufferedReader in = new BufferedReader(new InputStreamReader(fis));
String s = in.readLine();
while (s != null) {
consumer.consumeLine(s);
s = in.readLine();
}
Assert.assertEquals(2, consumer.getLines().size());
BlameLine line1 = (BlameLine) consumer.getLines().get(0);
Assert.assertEquals("1", line1.getRevision());
BlameLine line2 = (BlameLine) consumer.getLines().get(1);
Assert.assertEquals("2", line2.getRevision());
}
Aggregations