use of org.apache.maven.scm.command.diff.DiffScmResult in project maven-scm by apache.
the class BazaarDiffCommand method executeDiffCommand.
/**
* {@inheritDoc}
*/
protected DiffScmResult executeDiffCommand(ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion startRevision, ScmVersion endRevision) throws ScmException {
String[] diffCmd;
if (startRevision != null && StringUtils.isNotEmpty(startRevision.getName())) {
String revArg = startRevision.getName();
if (endRevision != null && StringUtils.isNotEmpty(endRevision.getName())) {
revArg += ".." + endRevision.getName();
}
diffCmd = new String[] { BazaarConstants.DIFF_CMD, BazaarConstants.REVISION_OPTION, revArg };
} else {
diffCmd = new String[] { BazaarConstants.DIFF_CMD };
}
diffCmd = BazaarUtils.expandCommandLine(diffCmd, fileSet);
BazaarDiffConsumer consumer = new BazaarDiffConsumer(getLogger(), fileSet.getBasedir());
ScmResult result = BazaarUtils.execute(consumer, getLogger(), fileSet.getBasedir(), diffCmd);
return new DiffScmResult(consumer.getChangedFiles(), consumer.getDifferences(), consumer.getPatch(), result);
}
use of org.apache.maven.scm.command.diff.DiffScmResult in project maven-scm by apache.
the class JGitDiffCommand method callDiff.
public DiffScmResult callDiff(Git git, ScmVersion startRevision, ScmVersion endRevision) throws IOException, GitAPIException, ScmException {
AbstractTreeIterator oldTree = null;
if (startRevision != null && StringUtils.isNotEmpty(startRevision.getName().trim())) {
String startRev = startRevision.getName().trim();
oldTree = getTreeIterator(git.getRepository(), startRev);
}
AbstractTreeIterator newTree = null;
if (endRevision != null && StringUtils.isNotEmpty(endRevision.getName().trim())) {
String endRev = endRevision.getName().trim();
newTree = getTreeIterator(git.getRepository(), endRev);
}
OutputStream out = new ByteArrayOutputStream();
git.diff().setOutputStream(out).setOldTree(oldTree).setNewTree(newTree).setCached(false).call();
git.diff().setOutputStream(out).setOldTree(oldTree).setNewTree(newTree).setCached(true).call();
out.flush();
GitDiffConsumer consumer = new GitDiffConsumer(getLogger(), null);
String fullDiff = out.toString();
out.close();
String[] lines = fullDiff.split("\n");
for (String aLine : lines) {
consumer.consumeLine(aLine);
}
return new DiffScmResult("JGit diff", consumer.getChangedFiles(), consumer.getDifferences(), consumer.getPatch());
}
use of org.apache.maven.scm.command.diff.DiffScmResult in project maven-scm by apache.
the class JGitDiffCommand method executeDiffCommand.
@Override
protected DiffScmResult executeDiffCommand(ScmProviderRepository repository, ScmFileSet fileSet, ScmVersion startRevision, ScmVersion endRevision) throws ScmException {
Git git = null;
try {
git = JGitUtils.openRepo(fileSet.getBasedir());
DiffScmResult diff = callDiff(git, startRevision, endRevision);
git.getRepository().close();
return diff;
} catch (Exception e) {
throw new ScmException("JGit diff failure!", e);
} finally {
JGitUtils.closeRepo(git);
}
}
use of org.apache.maven.scm.command.diff.DiffScmResult in project maven-scm by apache.
the class HgScmProvider method diff.
/**
* {@inheritDoc}
*/
public DiffScmResult diff(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
HgDiffCommand command = new HgDiffCommand();
command.setLogger(getLogger());
return (DiffScmResult) command.execute(repository, fileSet, parameters);
}
use of org.apache.maven.scm.command.diff.DiffScmResult in project maven-scm by apache.
the class CvsExeDiffCommand method executeCvsCommand.
/**
* {@inheritDoc}
*/
protected DiffScmResult executeCvsCommand(Commandline cl) throws ScmException {
CvsDiffConsumer consumer = new CvsDiffConsumer(getLogger(), cl.getWorkingDirectory());
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
try {
CommandLineUtils.executeCommandLine(cl, consumer, stderr);
} catch (CommandLineException ex) {
throw new ScmException("Error while executing command.", ex);
}
return new DiffScmResult(cl.toString(), consumer.getChangedFiles(), consumer.getDifferences(), consumer.getPatch());
}
Aggregations