use of org.apache.maven.scm.provider.cvslib.repository.CvsScmProviderRepository in project maven-scm by apache.
the class AbstractCvsCheckOutCommand method executeCommand.
@Override
public ScmResult executeCommand(ScmProviderRepository repo, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
ScmVersion version = parameters.getScmVersion(CommandParameter.SCM_VERSION, null);
boolean binary = parameters.getBoolean(CommandParameter.BINARY, false);
if (fileSet.getBasedir().exists()) {
try {
FileUtils.deleteDirectory(fileSet.getBasedir());
} catch (IOException e) {
if (getLogger().isWarnEnabled()) {
getLogger().warn("Can't delete " + fileSet.getBasedir().getAbsolutePath(), e);
}
}
}
CvsScmProviderRepository repository = (CvsScmProviderRepository) repo;
Commandline cl = CvsCommandUtils.getBaseCommand("checkout", repository, fileSet);
cl.setWorkingDirectory(fileSet.getBasedir().getParentFile().getAbsolutePath());
if (binary) {
cl.createArg().setValue("-kb");
}
if (version != null && !StringUtils.isEmpty(version.getName())) {
cl.createArg().setValue("-r");
cl.createArg().setValue(version.getName());
}
cl.createArg().setValue("-d");
cl.createArg().setValue(fileSet.getBasedir().getName());
cl.createArg().setValue(repository.getModule());
if (getLogger().isInfoEnabled()) {
getLogger().info("Executing: " + cl);
getLogger().info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath());
}
return executeCvsCommand(cl);
}
use of org.apache.maven.scm.provider.cvslib.repository.CvsScmProviderRepository in project maven-scm by apache.
the class AbstractCvsDiffCommand method executeDiffCommand.
/**
* {@inheritDoc}
*/
protected DiffScmResult executeDiffCommand(ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion startRevision, ScmVersion endRevision) throws ScmException {
CvsScmProviderRepository repository = (CvsScmProviderRepository) repo;
Commandline cl = CvsCommandUtils.getBaseCommand("diff", repository, fileSet);
cl.createArg().setValue("-u");
if (isSupportNewFileParameter()) {
cl.createArg().setValue("-N");
}
if (startRevision != null && StringUtils.isNotEmpty(startRevision.getName())) {
cl.createArg().setValue("-r");
cl.createArg().setValue(startRevision.getName());
}
if (endRevision != null && StringUtils.isNotEmpty(endRevision.getName())) {
cl.createArg().setValue("-r");
cl.createArg().setValue(endRevision.getName());
}
if (getLogger().isInfoEnabled()) {
getLogger().info("Executing: " + cl);
getLogger().info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath());
}
return executeCvsCommand(cl);
}
use of org.apache.maven.scm.provider.cvslib.repository.CvsScmProviderRepository in project maven-scm by apache.
the class AbstractCvsScmProvider method parseScmUrl.
// ----------------------------------------------------------------------
// Protected methods
// ----------------------------------------------------------------------
protected ScmUrlParserResult parseScmUrl(String scmSpecificUrl, char delimiter) {
ScmUrlParserResult result = new ScmUrlParserResult();
String[] tokens = StringUtils.split(scmSpecificUrl, Character.toString(delimiter));
if (tokens.length < 3) {
result.getMessages().add("The connection string contains too few tokens.");
return result;
}
String cvsroot;
String transport = tokens[0];
if (transport.equalsIgnoreCase(TRANSPORT_LOCAL)) {
// use the local repository directory eg. '/home/cvspublic'
cvsroot = tokens[1];
} else if (transport.equalsIgnoreCase(TRANSPORT_PSERVER) || transport.equalsIgnoreCase(TRANSPORT_LSERVER) || transport.equalsIgnoreCase(TRANSPORT_EXT) || transport.equalsIgnoreCase(TRANSPORT_SSPI)) {
if (tokens.length != 4 && transport.equalsIgnoreCase(TRANSPORT_EXT)) {
result.getMessages().add("The connection string contains too few tokens.");
return result;
} else if ((tokens.length < 4 || tokens.length > 6) && transport.equalsIgnoreCase(TRANSPORT_PSERVER)) {
result.getMessages().add("The connection string contains too few tokens.");
return result;
} else if (tokens.length < 4 || tokens.length > 5 && !transport.equalsIgnoreCase(TRANSPORT_PSERVER)) {
result.getMessages().add("The connection string contains too few tokens.");
return result;
} else if (tokens.length < 4 || tokens.length > 5 && transport.equalsIgnoreCase(TRANSPORT_SSPI)) {
result.getMessages().add("The connection string contains too few tokens.");
return result;
}
if (transport.equalsIgnoreCase(TRANSPORT_LSERVER)) {
// create the cvsroot as the local socket cvsroot
cvsroot = tokens[1] + ":" + tokens[2];
} else {
// create the cvsroot as the remote cvsroot
if (tokens.length == 4) {
cvsroot = ":" + transport + ":" + tokens[1] + ":" + tokens[2];
} else {
cvsroot = ":" + transport + ":" + tokens[1] + ":" + tokens[2] + ":" + tokens[3];
}
}
} else {
result.getMessages().add("Unknown transport: " + transport);
return result;
}
String user = null;
String password = null;
String host = null;
String path = null;
String module = null;
int port = -1;
if (transport.equalsIgnoreCase(TRANSPORT_PSERVER)) {
// set default port, it's necessary for checking entries in .cvspass
port = 2401;
if (tokens.length == 4) {
// pserver:[username@]host:path:module
String userhost = tokens[1];
int index = userhost.indexOf('@');
if (index == -1) {
host = userhost;
} else {
user = userhost.substring(0, index);
host = userhost.substring(index + 1);
}
path = tokens[2];
module = tokens[3];
} else if (tokens.length == 6) {
// pserver:username:password@host:port:path:module
user = tokens[1];
String passhost = tokens[2];
int index = passhost.indexOf('@');
if (index == -1) {
result.getMessages().add("The user_password_host part must be on the form: <username>:<password>@<hostname>.");
return result;
}
password = passhost.substring(0, index);
host = passhost.substring(index + 1);
port = Integer.valueOf(tokens[3]).intValue();
path = tokens[4];
module = tokens[5];
} else {
// tokens.length == 5
if (tokens[1].indexOf('@') > 0) {
// pserver:username@host:port:path:module
String userhost = tokens[1];
int index = userhost.indexOf('@');
user = userhost.substring(0, index);
host = userhost.substring(index + 1);
port = new Integer(tokens[2]).intValue();
} else if (tokens[2].indexOf('@') >= 0) {
// pserver:username:password@host:path:module
// <username>:<password>@<hostname>
user = tokens[1];
String passhost = tokens[2];
int index = passhost.indexOf('@');
password = passhost.substring(0, index);
host = passhost.substring(index + 1);
} else {
// pserver:host:port:path:module
try {
port = new Integer(tokens[2]).intValue();
} catch (Exception e) {
// incorrect
result.getMessages().add("Your scm url is invalid.");
return result;
}
host = tokens[1];
}
path = tokens[3];
module = tokens[4];
}
String userHost = host;
if (user != null) {
userHost = user + "@" + host;
}
// cvsroot format is :pserver:[user@]host:[port]path
cvsroot = ":" + transport + ":" + userHost + ":";
if (port != -1) {
cvsroot += port;
}
cvsroot += path;
} else if (transport.equalsIgnoreCase(TRANSPORT_SSPI)) {
// sspi:[username@]host:[port]path:module
String userhost = tokens[1];
int index = userhost.indexOf('@');
if (index == -1) {
user = "";
host = userhost;
} else {
user = userhost.substring(0, index);
host = userhost.substring(index + 1);
}
// no port specified
if (tokens.length == 4) {
path = tokens[2];
module = tokens[3];
} else {
// getting port
try {
port = new Integer(tokens[2]).intValue();
path = tokens[3];
module = tokens[4];
} catch (Exception e) {
// incorrect
result.getMessages().add("Your scm url is invalid, could not get port value.");
return result;
}
}
// cvsroot format is :sspi:host:path
cvsroot = ":" + transport + ":" + host + ":";
if (port != -1) {
cvsroot += port;
}
cvsroot += path;
} else {
if (!transport.equalsIgnoreCase(TRANSPORT_LOCAL)) {
String userhost = tokens[1];
int index = userhost.indexOf('@');
if (index == -1) {
host = userhost;
} else {
user = userhost.substring(0, index);
host = userhost.substring(index + 1);
}
}
if (transport.equals(TRANSPORT_LOCAL)) {
path = tokens[1];
module = tokens[2];
if (module != null && module.startsWith("/")) {
module = module.substring(1);
}
} else {
if (tokens.length == 4) {
path = tokens[2];
module = tokens[3];
} else {
port = new Integer(tokens[2]).intValue();
path = tokens[3];
module = tokens[4];
}
}
}
if (port == -1) {
result.setRepository(new CvsScmProviderRepository(cvsroot, transport, user, password, host, path, module));
} else {
result.setRepository(new CvsScmProviderRepository(cvsroot, transport, user, password, host, port, path, module));
}
return result;
}
use of org.apache.maven.scm.provider.cvslib.repository.CvsScmProviderRepository in project maven-scm by apache.
the class AbstractCvsBranchCommand method executeBranchCommand.
/**
* {@inheritDoc}
*/
protected ScmResult executeBranchCommand(ScmProviderRepository repo, ScmFileSet fileSet, String branchName, String message) throws ScmException {
CvsScmProviderRepository repository = (CvsScmProviderRepository) repo;
Commandline cl = CvsCommandUtils.getBaseCommand("tag", repository, fileSet, false);
cl.createArg().setValue("-b");
cl.createArg().setValue("-F");
cl.createArg().setValue("-c");
cl.createArg().setValue(branchName);
if (getLogger().isInfoEnabled()) {
getLogger().info("Executing: " + cl);
getLogger().info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath());
}
return executeCvsCommand(cl);
}
use of org.apache.maven.scm.provider.cvslib.repository.CvsScmProviderRepository in project maven-scm by apache.
the class AbstractCvsChangeLogCommand method executeChangeLogCommand.
private ChangeLogScmResult executeChangeLogCommand(ScmProviderRepository repo, ScmFileSet fileSet, Date startDate, Date endDate, ScmBranch branch, ScmVersion startVersion, ScmVersion endVersion, String datePattern) throws ScmException {
CvsScmProviderRepository repository = (CvsScmProviderRepository) repo;
Commandline cl = CvsCommandUtils.getBaseCommand("log", repository, fileSet);
if (startDate != null) {
SimpleDateFormat outputDate = new SimpleDateFormat(getDateFormat());
String dateRange;
if (endDate == null) {
dateRange = ">" + outputDate.format(startDate);
} else {
dateRange = outputDate.format(startDate) + "<" + outputDate.format(endDate);
}
cl.createArg().setValue("-d");
addDateRangeParameter(cl, dateRange);
}
if (branch != null && StringUtils.isNotEmpty(branch.getName())) {
cl.createArg().setValue("-r" + branch.getName());
}
if (startVersion != null || endVersion != null) {
StringBuilder sb = new StringBuilder();
sb.append("-r");
if (startVersion != null && StringUtils.isNotEmpty(startVersion.getName())) {
sb.append(startVersion.getName());
}
sb.append("::");
if (endVersion != null && StringUtils.isNotEmpty(endVersion.getName())) {
sb.append(endVersion.getName());
}
cl.createArg().setValue(sb.toString());
}
if (getLogger().isInfoEnabled()) {
getLogger().info("Executing: " + cl);
getLogger().info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath());
}
return executeCvsCommand(cl, startDate, endDate, startVersion, endVersion, datePattern);
}
Aggregations