Search in sources :

Example 11 with CvsScmProviderRepository

use of org.apache.maven.scm.provider.cvslib.repository.CvsScmProviderRepository in project maven-scm by apache.

the class AbstractCvsCheckInCommand method executeCheckInCommand.

/**
 * {@inheritDoc}
 */
protected CheckInScmResult executeCheckInCommand(ScmProviderRepository repo, ScmFileSet fileSet, String message, ScmVersion version) throws ScmException {
    CvsScmProviderRepository repository = (CvsScmProviderRepository) repo;
    Commandline cl = CvsCommandUtils.getBaseCommand("commit", repository, fileSet, false);
    if (version != null && !StringUtils.isEmpty(version.getName())) {
        cl.createArg().setValue("-r" + version.getName());
    }
    cl.createArg().setValue("-R");
    cl.createArg().setValue("-F");
    File messageFile;
    try {
        messageFile = File.createTempFile("scm-commit-message", ".txt");
        FileUtils.fileWrite(messageFile.getAbsolutePath(), message);
    } catch (IOException ex) {
        throw new ScmException("Error while making a temporary commit message file.");
    }
    cl.createArg().setValue(messageFile.getAbsolutePath());
    List<File> files = fileSet.getFileList();
    for (File f : files) {
        cl.createArg().setValue(f.getPath().replace('\\', '/'));
    }
    if (getLogger().isInfoEnabled()) {
        getLogger().info("Executing: " + cl);
        getLogger().info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath());
    }
    CheckInScmResult result = executeCvsCommand(cl, repository, messageFile);
    try {
        FileUtils.forceDelete(messageFile);
    } catch (IOException ex) {
    // ignore
    }
    return result;
}
Also used : ScmException(org.apache.maven.scm.ScmException) CvsScmProviderRepository(org.apache.maven.scm.provider.cvslib.repository.CvsScmProviderRepository) Commandline(org.codehaus.plexus.util.cli.Commandline) IOException(java.io.IOException) File(java.io.File) CheckInScmResult(org.apache.maven.scm.command.checkin.CheckInScmResult)

Example 12 with CvsScmProviderRepository

use of org.apache.maven.scm.provider.cvslib.repository.CvsScmProviderRepository in project maven-scm by apache.

the class AbstractCvsExportCommand method executeExportCommand.

/**
 * {@inheritDoc}
 */
protected ExportScmResult executeExportCommand(ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion version, String outputDirectory) throws ScmException {
    CvsScmProviderRepository repository = (CvsScmProviderRepository) repo;
    Commandline cl = CvsCommandUtils.getBaseCommand("export", repository, fileSet);
    if (version != null && StringUtils.isNotEmpty(version.getName())) {
        cl.createArg().setValue("-r" + version.getName());
    } else {
        cl.createArg().setValue("-rHEAD");
    }
    if (StringUtils.isNotEmpty(outputDirectory)) {
        cl.createArg().setValue("-d");
        cl.createArg().setValue(outputDirectory);
    }
    cl.createArg().setValue(repository.getModule());
    if (getLogger().isInfoEnabled()) {
        getLogger().info("Executing: " + cl);
        getLogger().info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath());
    }
    return executeCvsCommand(cl);
}
Also used : CvsScmProviderRepository(org.apache.maven.scm.provider.cvslib.repository.CvsScmProviderRepository) Commandline(org.codehaus.plexus.util.cli.Commandline)

Example 13 with CvsScmProviderRepository

use of org.apache.maven.scm.provider.cvslib.repository.CvsScmProviderRepository in project maven-scm by apache.

the class AbstractCvsRemoveCommand method executeRemoveCommand.

/**
 * {@inheritDoc}
 */
protected ScmResult executeRemoveCommand(ScmProviderRepository repo, ScmFileSet fileSet, String message) throws ScmException {
    CvsScmProviderRepository repository = (CvsScmProviderRepository) repo;
    Commandline cl = CvsCommandUtils.getBaseCommand("remove", repository, fileSet);
    cl.createArg().setValue("-f");
    cl.createArg().setValue("-l");
    List<File> files = fileSet.getFileList();
    List<ScmFile> removedFiles = new ArrayList<ScmFile>();
    for (File file : files) {
        String path = file.getPath().replace('\\', '/');
        cl.createArg().setValue(path);
        removedFiles.add(new ScmFile(path, ScmFileStatus.DELETED));
    }
    if (getLogger().isInfoEnabled()) {
        getLogger().info("Executing: " + cl);
        getLogger().info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath());
    }
    return executeCvsCommand(cl, removedFiles);
}
Also used : CvsScmProviderRepository(org.apache.maven.scm.provider.cvslib.repository.CvsScmProviderRepository) Commandline(org.codehaus.plexus.util.cli.Commandline) ArrayList(java.util.ArrayList) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) ScmFile(org.apache.maven.scm.ScmFile)

Example 14 with CvsScmProviderRepository

use of org.apache.maven.scm.provider.cvslib.repository.CvsScmProviderRepository in project maven-scm by apache.

the class CvsExeScmProvider method parseScmUrl.

/**
 * {@inheritDoc}
 */
protected ScmUrlParserResult parseScmUrl(String scmSpecificUrl, char delimiter) {
    ScmUrlParserResult result = super.parseScmUrl(scmSpecificUrl, delimiter);
    if (result.getMessages().isEmpty()) {
        return result;
    }
    result.resetMessages();
    String[] tokens = StringUtils.split(scmSpecificUrl, Character.toString(delimiter));
    String cvsroot;
    String transport = tokens[0];
    // support sserver
    if (transport.equalsIgnoreCase(TRANSPORT_SSERVER)) {
        if (tokens.length < 4 || tokens.length > 5 && transport.equalsIgnoreCase(TRANSPORT_SSERVER)) {
            result.getMessages().add("The connection string contains too few tokens.");
            return result;
        }
        // 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_SSERVER)) {
        // 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 = Integer.valueOf(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;
    }
    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;
}
Also used : CvsScmProviderRepository(org.apache.maven.scm.provider.cvslib.repository.CvsScmProviderRepository)

Example 15 with CvsScmProviderRepository

use of org.apache.maven.scm.provider.cvslib.repository.CvsScmProviderRepository in project maven-scm by apache.

the class AbstractCvsListCommand method executeListCommand1.

private ListScmResult executeListCommand1(ScmProviderRepository repo, ScmFileSet fileSet, boolean recursive, ScmVersion version, Boolean supD) throws ScmException {
    CvsScmProviderRepository repository = (CvsScmProviderRepository) repo;
    Commandline cl = CvsCommandUtils.getBaseCommand("rls", repository, fileSet, "-n");
    if (version != null && !StringUtils.isEmpty(version.getName())) {
        cl.createArg().setValue("-r");
        cl.createArg().setValue(version.getName());
    }
    if (supD != Boolean.FALSE) {
        cl.createArg().setValue("-d");
    }
    // szakusov: to fix "Unknown file status" problem
    cl.createArg().setValue("-e");
    if (recursive) {
        cl.createArg().setValue("-R");
    }
    String modulePref = repository.getModule();
    if (!StringUtils.isEmpty(modulePref)) {
        modulePref += File.separatorChar;
    } else {
        modulePref = "";
    }
    for (Iterator<File> it = fileSet.getFileList().iterator(); it.hasNext(); ) {
        File target = (File) it.next();
        String path = target.getPath();
        if (path.startsWith("\\")) {
            path = path.substring(1);
        }
        path = modulePref + path;
        cl.createArg().setValue(path);
    }
    if (getLogger().isInfoEnabled()) {
        getLogger().info("Executing: " + cl);
        getLogger().info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath());
    }
    return executeCvsCommand(cl);
}
Also used : CvsScmProviderRepository(org.apache.maven.scm.provider.cvslib.repository.CvsScmProviderRepository) Commandline(org.codehaus.plexus.util.cli.Commandline) File(java.io.File)

Aggregations

CvsScmProviderRepository (org.apache.maven.scm.provider.cvslib.repository.CvsScmProviderRepository)17 Commandline (org.codehaus.plexus.util.cli.Commandline)13 File (java.io.File)6 IOException (java.io.IOException)4 ScmException (org.apache.maven.scm.ScmException)3 ArrayList (java.util.ArrayList)2 ScmFile (org.apache.maven.scm.ScmFile)2 SimpleDateFormat (java.text.SimpleDateFormat)1 ScmVersion (org.apache.maven.scm.ScmVersion)1 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)1 LoginScmResult (org.apache.maven.scm.command.login.LoginScmResult)1 SvnScmProviderRepository (org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository)1 Settings (org.apache.maven.scm.providers.cvslib.settings.Settings)1 ScmRepository (org.apache.maven.scm.repository.ScmRepository)1 ScmRepositoryException (org.apache.maven.scm.repository.ScmRepositoryException)1