use of org.apache.maven.scm.command.changelog.ChangeLogSet in project maven-scm by apache.
the class BazaarChangeLogCommand method executeChangeLogCommand.
private ChangeLogScmResult executeChangeLogCommand(ScmFileSet fileSet, Date startDate, Date endDate, String datePattern, Integer limit) throws ScmException {
List<String> cmd = new ArrayList<String>();
cmd.addAll(Arrays.asList(BazaarConstants.LOG_CMD, BazaarConstants.VERBOSE_OPTION));
if (limit != null && limit > 0) {
cmd.add(BazaarConstants.LIMIT_OPTION);
cmd.add(Integer.toString(limit));
}
BazaarChangeLogConsumer consumer = new BazaarChangeLogConsumer(getLogger(), datePattern);
ScmResult result = BazaarUtils.execute(consumer, getLogger(), fileSet.getBasedir(), cmd.toArray(new String[cmd.size()]));
List<ChangeSet> logEntries = consumer.getModifications();
List<ChangeSet> inRangeAndValid = new ArrayList<ChangeSet>();
// From 1. Jan 1970
startDate = startDate == null ? new Date(0) : startDate;
// Upto now
endDate = endDate == null ? new Date() : endDate;
for (ChangeSet change : logEntries) {
if (change.getFiles().size() > 0) {
if (!change.getDate().before(startDate) && !change.getDate().after(endDate)) {
inRangeAndValid.add(change);
}
}
}
ChangeLogSet changeLogSet = new ChangeLogSet(inRangeAndValid, startDate, endDate);
return new ChangeLogScmResult(changeLogSet, result);
}
use of org.apache.maven.scm.command.changelog.ChangeLogSet in project maven-scm by apache.
the class PerforceChangeLogCommand method executeChangeLogCommand.
protected ChangeLogScmResult executeChangeLogCommand(ScmProviderRepository repo, ScmFileSet fileSet, Date startDate, Date endDate, ScmBranch branch, String datePattern, ScmVersion startVersion, ScmVersion endVersion) throws ScmException {
PerforceScmProviderRepository p4repo = (PerforceScmProviderRepository) repo;
String clientspec = PerforceScmProvider.getClientspecName(getLogger(), p4repo, fileSet.getBasedir());
Commandline cl = createCommandLine(p4repo, fileSet.getBasedir(), clientspec, null, startDate, endDate, startVersion, endVersion);
String location = PerforceScmProvider.getRepoPath(getLogger(), p4repo, fileSet.getBasedir());
PerforceChangesConsumer consumer = new PerforceChangesConsumer(getLogger());
try {
if (getLogger().isDebugEnabled()) {
getLogger().debug(PerforceScmProvider.clean("Executing " + cl.toString()));
}
CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
int exitCode = CommandLineUtils.executeCommandLine(cl, consumer, err);
if (exitCode != 0) {
String cmdLine = CommandLineUtils.toString(cl.getCommandline());
StringBuilder msg = new StringBuilder("Exit code: " + exitCode + " - " + err.getOutput());
msg.append('\n');
msg.append("Command line was:" + cmdLine);
throw new CommandLineException(msg.toString());
}
} catch (CommandLineException e) {
if (getLogger().isErrorEnabled()) {
getLogger().error("CommandLineException " + e.getMessage(), e);
}
}
List<String> changes = consumer.getChanges();
cl = PerforceScmProvider.createP4Command(p4repo, fileSet.getBasedir());
cl.createArg().setValue("describe");
cl.createArg().setValue("-s");
for (String change : changes) {
cl.createArg().setValue(change);
}
PerforceDescribeConsumer describeConsumer = new PerforceDescribeConsumer(location, datePattern, getLogger());
try {
if (getLogger().isDebugEnabled()) {
getLogger().debug(PerforceScmProvider.clean("Executing " + cl.toString()));
}
CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
int exitCode = CommandLineUtils.executeCommandLine(cl, describeConsumer, err);
if (exitCode != 0) {
String cmdLine = CommandLineUtils.toString(cl.getCommandline());
StringBuilder msg = new StringBuilder("Exit code: " + exitCode + " - " + err.getOutput());
msg.append('\n');
msg.append("Command line was:" + cmdLine);
throw new CommandLineException(msg.toString());
}
} catch (CommandLineException e) {
if (getLogger().isErrorEnabled()) {
getLogger().error("CommandLineException " + e.getMessage(), e);
}
}
ChangeLogSet cls = new ChangeLogSet(describeConsumer.getModifications(), null, null);
cls.setStartVersion(startVersion);
cls.setEndVersion(endVersion);
return new ChangeLogScmResult(cl.toString(), cls);
}
use of org.apache.maven.scm.command.changelog.ChangeLogSet in project maven-scm by apache.
the class ClearCaseChangeLogCommand method executeChangeLogCommand.
// ----------------------------------------------------------------------
// AbstractChangeLogCommand Implementation
// ----------------------------------------------------------------------
/**
* {@inheritDoc}
*/
protected ChangeLogScmResult executeChangeLogCommand(ScmProviderRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, ScmBranch branch, String datePattern) throws ScmException {
if (getLogger().isDebugEnabled()) {
getLogger().debug("executing changelog command...");
}
Commandline cl = createCommandLine(fileSet.getBasedir(), branch, startDate);
ClearCaseChangeLogConsumer consumer = new ClearCaseChangeLogConsumer(getLogger(), datePattern);
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
int exitCode;
try {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Executing: " + cl.getWorkingDirectory().getAbsolutePath() + ">>" + cl.toString());
}
exitCode = CommandLineUtils.executeCommandLine(cl, consumer, stderr);
} catch (CommandLineException ex) {
throw new ScmException("Error while executing cvs command.", ex);
}
if (exitCode != 0) {
return new ChangeLogScmResult(cl.toString(), "The cleartool command failed.", stderr.getOutput(), false);
}
return new ChangeLogScmResult(cl.toString(), new ChangeLogSet(consumer.getModifications(), startDate, endDate));
}
use of org.apache.maven.scm.command.changelog.ChangeLogSet in project maven-scm by apache.
the class CvsExeChangeLogCommand method executeCvsCommand.
/**
* {@inheritDoc}
*/
protected ChangeLogScmResult executeCvsCommand(Commandline cl, Date startDate, Date endDate, ScmVersion startVersion, ScmVersion endVersion, String datePattern) throws ScmException {
CvsChangeLogConsumer consumer = new CvsChangeLogConsumer(getLogger(), datePattern);
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
int exitCode;
try {
exitCode = CommandLineUtils.executeCommandLine(cl, consumer, stderr);
} catch (CommandLineException ex) {
throw new ScmException("Error while executing cvs command.", ex);
}
if (exitCode != 0) {
return new ChangeLogScmResult(cl.toString(), "The cvs command failed.", stderr.getOutput(), false);
}
ChangeLogSet changeLogSet = new ChangeLogSet(consumer.getModifications(), startDate, endDate);
changeLogSet.setStartVersion(startVersion);
changeLogSet.setEndVersion(endVersion);
return new ChangeLogScmResult(cl.toString(), changeLogSet);
}
use of org.apache.maven.scm.command.changelog.ChangeLogSet in project maven-scm by apache.
the class CvsJavaChangeLogCommand method executeCvsCommand.
/**
* {@inheritDoc}
*/
protected ChangeLogScmResult executeCvsCommand(Commandline cl, Date startDate, Date endDate, ScmVersion startVersion, ScmVersion endVersion, String datePattern) throws ScmException {
CvsLogListener logListener = new CvsLogListener();
CvsChangeLogConsumer consumer = new CvsChangeLogConsumer(getLogger(), datePattern);
try {
boolean isSuccess = CvsConnection.processCommand(cl.getArguments(), cl.getWorkingDirectory().getAbsolutePath(), logListener, getLogger());
if (!isSuccess) {
return new ChangeLogScmResult(cl.toString(), "The cvs command failed.", logListener.getStderr().toString(), false);
}
BufferedReader stream = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(logListener.getStdout().toString().getBytes())));
String line;
while ((line = stream.readLine()) != null) {
consumer.consumeLine(line);
}
} catch (Exception e) {
e.printStackTrace();
return new ChangeLogScmResult(cl.toString(), "The cvs command failed.", logListener.getStdout().toString(), false);
}
ChangeLogSet changeLogSet = new ChangeLogSet(consumer.getModifications(), startDate, endDate);
changeLogSet.setStartVersion(startVersion);
changeLogSet.setEndVersion(endVersion);
return new ChangeLogScmResult(cl.toString(), changeLogSet);
}
Aggregations