use of org.apache.maven.scm.provider.accurev.AccuRev in project maven-scm by apache.
the class AccuRevCheckInCommand method executeAccurevCommand.
@Override
protected ScmResult executeAccurevCommand(AccuRevScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException, AccuRevException {
AccuRev accuRev = repository.getAccuRev();
String message = parameters.getString(CommandParameter.MESSAGE);
List<File> promotedFiles = null;
File basedir = fileSet.getBasedir();
List<File> fileList = fileSet.getFileList();
if (fileList.isEmpty()) {
// TODO the above test will be matched by a fileset where excludes and includes produce a set with no files.
// This is
// NOT the same as a fileset created with only a base directory. Raise maven-scm JIRA for this.
AccuRevInfo info = accuRev.info(basedir);
if (repository.isWorkSpaceRoot(info)) {
promotedFiles = accuRev.promoteAll(basedir, message);
} else {
throw new ScmException(String.format("Unsupported recursive checkin for %s. Not the workspace root", basedir.getAbsolutePath()));
}
} else {
promotedFiles = accuRev.promote(basedir, fileList, message);
}
if (promotedFiles != null) {
Iterator<File> iter = promotedFiles.iterator();
while (iter.hasNext()) {
if (new File(basedir, iter.next().getPath()).isDirectory()) {
iter.remove();
}
}
// TODO capture the transaction id from the promote
return new CheckInScmResult(accuRev.getCommandLines(), getScmFiles(promotedFiles, ScmFileStatus.CHECKED_IN));
} else {
return new CheckInScmResult(accuRev.getCommandLines(), "AccuRev Error", accuRev.getErrorOutput(), false);
}
}
use of org.apache.maven.scm.provider.accurev.AccuRev in project maven-scm by apache.
the class AccuRevAddCommand method executeAccurevCommand.
/**
* Add.
*
* @todo handle the "binary" parameter. AccuRev does a reasonable job of detecting this itself.
*/
protected ScmResult executeAccurevCommand(AccuRevScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException, AccuRevException {
AccuRev accuRev = repository.getAccuRev();
String message = parameters.getString(CommandParameter.MESSAGE, "");
File basedir = fileSet.getBasedir();
List<File> relativeFiles = fileSet.getFileList();
List<File> addedFiles = accuRev.add(basedir, relativeFiles, message);
if (addedFiles != null) {
List<ScmFile> resultFiles = getScmFiles(addedFiles, ScmFileStatus.ADDED);
return new AddScmResult(accuRev.getCommandLines(), resultFiles);
} else {
return new AddScmResult(accuRev.getCommandLines(), "AccuRev Error", accuRev.getErrorOutput(), false);
}
}
use of org.apache.maven.scm.provider.accurev.AccuRev in project maven-scm by apache.
the class AccuRevLoginCommand method executeAccurevCommand.
@Override
protected ScmResult executeAccurevCommand(AccuRevScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException, AccuRevException {
boolean result = false;
AccuRev accurev = repository.getAccuRev();
AccuRevInfo info = accurev.info(null);
String providerMessage = "";
if (info == null) {
providerMessage = "Unable to retrieve accurev info";
} else if (repository.getUser() != null) {
// Check if we've already logged in as this user
result = repository.getUser().equals(info.getUser());
if (result) {
providerMessage = "Skipping login - already logged in as " + repository.getUser();
} else {
result = accurev.login(repository.getUser(), repository.getPassword());
providerMessage = (result ? "Success" : "Failure") + " logging in as " + repository.getUser();
}
} else {
result = info.isLoggedIn();
providerMessage = result ? ("Logged in externally as " + info.getUser()) : "Not logged in";
}
getLogger().debug(providerMessage);
return new LoginScmResult(accurev.getCommandLines(), providerMessage, accurev.getErrorOutput(), result);
}
use of org.apache.maven.scm.provider.accurev.AccuRev in project maven-scm by apache.
the class AccuRevUpdateCommand method executeAccurevCommand.
@Override
protected ScmResult executeAccurevCommand(AccuRevScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException, AccuRevException {
AccuRev accuRev = repository.getAccuRev();
File basedir = fileSet.getBasedir();
AccuRevInfo info = accuRev.info(basedir);
if (!info.isWorkSpace()) {
throw new AccuRevException("No workspace at " + basedir.getAbsolutePath());
}
String startRevision = getStartRevision(repository, parameters, info);
ScmVersion scmVersion = parameters.getScmVersion(CommandParameter.SCM_VERSION, null);
String updateTransactionId = null;
if (scmVersion != null) {
AccuRevVersion updateVersion = repository.getAccuRevVersion(scmVersion);
// Reparent if necessary
String newBasisStream = updateVersion.getBasisStream();
if (newBasisStream != null && (!(newBasisStream.equals(info.getWorkSpace()) || newBasisStream.equals(info.getBasis())))) {
getLogger().info("Reparenting " + info.getWorkSpace() + " to " + newBasisStream);
accuRev.chws(basedir, info.getWorkSpace(), newBasisStream);
}
if (!updateVersion.isNow()) {
updateTransactionId = updateVersion.getTimeSpec();
}
}
if (updateTransactionId == null) {
updateTransactionId = repository.getDepotTransactionId(info.getWorkSpace(), "now");
}
String endRevision = repository.getRevision(info.getWorkSpace(), updateTransactionId);
List<File> updatedFiles = accuRev.update(basedir, updateTransactionId);
if (updatedFiles != null) {
return new AccuRevUpdateScmResult(accuRev.getCommandLines(), getScmFiles(updatedFiles, ScmFileStatus.UPDATED), startRevision, endRevision);
} else {
return new AccuRevUpdateScmResult(accuRev.getCommandLines(), "AccuRev error", accuRev.getErrorOutput(), null, null, false);
}
}
use of org.apache.maven.scm.provider.accurev.AccuRev 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);
}
}
Aggregations