use of org.apache.maven.scm.command.branch.BranchScmResult in project maven-scm by apache.
the class IntegrityScmProvider method branch.
/**
* Maps to si createdevpath
*/
@Override
protected BranchScmResult branch(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params) throws ScmException {
IntegrityBranchCommand command = new IntegrityBranchCommand();
command.setLogger(getLogger());
return (BranchScmResult) command.execute(repository, fileSet, params);
}
use of org.apache.maven.scm.command.branch.BranchScmResult in project maven-scm by apache.
the class HgScmProvider method branch.
/**
* {@inheritDoc}
*/
public BranchScmResult branch(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
HgBranchCommand command = new HgBranchCommand();
command.setLogger(getLogger());
return (BranchScmResult) command.execute(repository, fileSet, parameters);
}
use of org.apache.maven.scm.command.branch.BranchScmResult in project maven-scm by apache.
the class HgBranchCommand method executeBranchCommand.
/**
* {@inheritDoc}
*/
protected ScmResult executeBranchCommand(ScmProviderRepository scmProviderRepository, ScmFileSet fileSet, String branch, ScmBranchParameters scmBranchParameters) throws ScmException {
if (StringUtils.isBlank(branch)) {
throw new ScmException("branch must be specified");
}
if (!fileSet.getFileList().isEmpty()) {
throw new ScmException("This provider doesn't support branchging subsets of a directory");
}
File workingDir = fileSet.getBasedir();
// build the command
String[] branchCmd = new String[] { HgCommandConstants.BRANCH_CMD, branch };
// keep the command about in string form for reporting
HgConsumer branchConsumer = new HgConsumer(getLogger()) {
public void doConsume(ScmFileStatus status, String trimmedLine) {
// noop
}
};
ScmResult result = HgUtils.execute(branchConsumer, getLogger(), workingDir, branchCmd);
HgScmProviderRepository repository = (HgScmProviderRepository) scmProviderRepository;
if (!result.isSuccess()) {
throw new ScmException("Error while executing command " + joinCmd(branchCmd));
}
// First commit.
String[] commitCmd = new String[] { HgCommandConstants.COMMIT_CMD, HgCommandConstants.MESSAGE_OPTION, scmBranchParameters.getMessage() };
result = HgUtils.execute(new HgConsumer(getLogger()), getLogger(), workingDir, commitCmd);
if (!result.isSuccess()) {
throw new ScmException("Error while executing command " + joinCmd(commitCmd));
}
if (repository.isPushChanges()) {
if (!repository.getURI().equals(fileSet.getBasedir().getAbsolutePath())) {
String[] pushCmd = new String[] { HgCommandConstants.PUSH_CMD, HgCommandConstants.NEW_BRANCH_OPTION, repository.getURI() };
result = HgUtils.execute(new HgConsumer(getLogger()), getLogger(), fileSet.getBasedir(), pushCmd);
if (!result.isSuccess()) {
throw new ScmException("Error while executing command " + joinCmd(pushCmd));
}
}
}
// do an inventory to return the files branched (all of them)
String[] listCmd = new String[] { HgCommandConstants.INVENTORY_CMD };
HgListConsumer listconsumer = new HgListConsumer(getLogger());
result = HgUtils.execute(listconsumer, getLogger(), fileSet.getBasedir(), listCmd);
if (!result.isSuccess()) {
throw new ScmException("Error while executing command " + joinCmd(listCmd));
}
List<ScmFile> files = listconsumer.getFiles();
List<ScmFile> fileList = new ArrayList<ScmFile>();
for (ScmFile f : files) {
fileList.add(new ScmFile(f.getPath(), ScmFileStatus.TAGGED));
}
return new BranchScmResult(fileList, result);
}
use of org.apache.maven.scm.command.branch.BranchScmResult in project maven-scm by apache.
the class CvsExeBranchCommand method executeCvsCommand.
/**
* {@inheritDoc}
*/
protected BranchScmResult executeCvsCommand(Commandline cl) throws ScmException {
int exitCode;
CvsBranchConsumer consumer = new CvsBranchConsumer(getLogger());
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
try {
exitCode = CommandLineUtils.executeCommandLine(cl, consumer, stderr);
} catch (CommandLineException ex) {
throw new ScmException("Error while executing command.", ex);
}
if (exitCode != 0) {
return new BranchScmResult(cl.toString(), "The cvs branch command failed.", stderr.getOutput(), false);
}
return new BranchScmResult(cl.toString(), consumer.getTaggedFiles());
}
use of org.apache.maven.scm.command.branch.BranchScmResult in project maven-scm by apache.
the class TfsBranchCommand method executeBranchCommand.
protected ScmResult executeBranchCommand(ScmProviderRepository r, ScmFileSet f, String branch, String message) throws ScmException {
TfsCommand command = createCommand(r, f, branch);
StringStreamConsumer out = new StringStreamConsumer();
ErrorStreamConsumer err = new ErrorStreamConsumer();
int status = command.execute(out, err);
getLogger().info("status of branch command is= " + status + "; err= " + err.getOutput());
if (status != 0 || err.hasBeenFed()) {
return new BranchScmResult(command.getCommandString(), "Error code for TFS branch command - " + status, err.getOutput(), false);
}
return new BranchScmResult(command.getCommandString(), new ArrayList<ScmFile>(0));
}
Aggregations