Search in sources :

Example 91 with ScmFile

use of org.apache.maven.scm.ScmFile in project maven-scm by apache.

the class SynergyRemoveCommand method executeRemoveCommand.

/**
 * {@inheritDoc}
 */
protected ScmResult executeRemoveCommand(ScmProviderRepository repository, ScmFileSet fileSet, String message) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing remove command...");
    }
    SynergyScmProviderRepository repo = (SynergyScmProviderRepository) repository;
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("basedir: " + fileSet.getBasedir());
    }
    String ccmAddr = SynergyUtil.start(getLogger(), repo.getUser(), repo.getPassword(), null);
    try {
        String projectSpec = SynergyUtil.getWorkingProject(getLogger(), repo.getProjectSpec(), repo.getUser(), ccmAddr);
        if (projectSpec == null) {
            throw new ScmException("You should checkout a working project first");
        }
        File waPath = SynergyUtil.getWorkArea(getLogger(), projectSpec, ccmAddr);
        File destPath = new File(waPath, repo.getProjectName());
        for (File f : fileSet.getFileList()) {
            File source = new File(fileSet.getBasedir(), f.getPath());
            File dest = new File(destPath, f.getPath());
            SynergyUtil.delete(getLogger(), dest, ccmAddr, false);
            if (!source.equals(dest)) {
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("Delete file [" + source + "].");
                }
                dest.delete();
            }
        }
    } finally {
        SynergyUtil.stop(getLogger(), ccmAddr);
    }
    List<ScmFile> scmFiles = new ArrayList<ScmFile>();
    for (File file : fileSet.getFileList()) {
        scmFiles.add(new ScmFile(file.getPath(), ScmFileStatus.DELETED));
    }
    return new StatusScmResult("", scmFiles);
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) ScmException(org.apache.maven.scm.ScmException) SynergyScmProviderRepository(org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository) ArrayList(java.util.ArrayList) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) ScmFile(org.apache.maven.scm.ScmFile)

Example 92 with ScmFile

use of org.apache.maven.scm.ScmFile in project maven-scm by apache.

the class SynergyUpdateCommand method executeUpdateCommand.

/**
 * {@inheritDoc}
 */
protected UpdateScmResult executeUpdateCommand(ScmProviderRepository repository, ScmFileSet fileSet, ScmVersion version) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing update command...");
    }
    SynergyScmProviderRepository repo = (SynergyScmProviderRepository) repository;
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("basedir: " + fileSet.getBasedir());
    }
    String ccmAddr = SynergyUtil.start(getLogger(), repo.getUser(), repo.getPassword(), null);
    File waPath;
    try {
        String projectSpec = SynergyUtil.getWorkingProject(getLogger(), repo.getProjectSpec(), repo.getUser(), ccmAddr);
        SynergyUtil.reconfigureProperties(getLogger(), projectSpec, ccmAddr);
        SynergyUtil.reconfigure(getLogger(), projectSpec, ccmAddr);
        // We need to get WA path
        waPath = SynergyUtil.getWorkArea(getLogger(), projectSpec, ccmAddr);
    } finally {
        SynergyUtil.stop(getLogger(), ccmAddr);
    }
    File source = new File(waPath, repo.getProjectName());
    // Move file from work area to expected dir if not the same
    List<ScmFile> modifications = new ArrayList<ScmFile>();
    if (!source.equals(fileSet.getBasedir())) {
        if (getLogger().isInfoEnabled()) {
            getLogger().info("We will copy modified files from Synergy Work Area [" + source + "] to expected folder [" + fileSet.getBasedir() + "]");
        }
        try {
            copyDirectoryStructure(source, fileSet.getBasedir(), modifications);
        } catch (IOException e1) {
            throw new ScmException("Unable to copy directory structure", e1);
        }
    }
    return new UpdateScmResult("ccm reconcile -uwa ...", modifications);
}
Also used : ScmException(org.apache.maven.scm.ScmException) SynergyScmProviderRepository(org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository) ArrayList(java.util.ArrayList) UpdateScmResult(org.apache.maven.scm.command.update.UpdateScmResult) IOException(java.io.IOException) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) ScmFile(org.apache.maven.scm.ScmFile)

Example 93 with ScmFile

use of org.apache.maven.scm.ScmFile in project maven-scm by apache.

the class StarteamCheckOutConsumer method processCheckedOutFile.

private void processCheckedOutFile(String line, int pos) {
    String checkedOutFilePath = this.currentDir + "/" + line.substring(0, pos);
    this.files.add(new ScmFile(checkedOutFilePath, ScmFileStatus.CHECKED_OUT));
    if (logger.isInfoEnabled()) {
        logger.info("Checked out: " + checkedOutFilePath);
    }
}
Also used : ScmFile(org.apache.maven.scm.ScmFile)

Example 94 with ScmFile

use of org.apache.maven.scm.ScmFile in project maven-scm by apache.

the class StarteamDiffConsumer method extractCurrentFile.

private void extractCurrentFile(String line, int pos) {
    currentFile = line.substring(0, pos);
    changedFiles.add(new ScmFile(currentFile, ScmFileStatus.MODIFIED));
    currentDifference = new StringBuilder();
    differences.put(currentFile, currentDifference);
}
Also used : ScmFile(org.apache.maven.scm.ScmFile)

Example 95 with ScmFile

use of org.apache.maven.scm.ScmFile in project maven-scm by apache.

the class StarteamRemoveConsumerTest method testParse.

public void testParse() throws Exception {
    File basedir = new File("/usr/scm-starteam/driver");
    StarteamRemoveConsumer consumer = new StarteamRemoveConsumer(new DefaultLog(), basedir);
    for (int i = 0; i < TEST_OUTPUT.length; ++i) {
        consumer.consumeLine(TEST_OUTPUT[i]);
    }
    Collection<ScmFile> entries = consumer.getRemovedFiles();
    assertEquals("Wrong number of entries returned", 7, entries.size());
    for (ScmFile entry : entries) {
        assertTrue(entry.getPath().startsWith("./"));
        assertTrue(entry.getStatus() == ScmFileStatus.DELETED);
    }
}
Also used : DefaultLog(org.apache.maven.scm.log.DefaultLog) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) ScmFile(org.apache.maven.scm.ScmFile)

Aggregations

ScmFile (org.apache.maven.scm.ScmFile)198 File (java.io.File)102 ArrayList (java.util.ArrayList)51 ScmException (org.apache.maven.scm.ScmException)34 BufferedReader (java.io.BufferedReader)21 DefaultLog (org.apache.maven.scm.log.DefaultLog)20 ScmFileStatus (org.apache.maven.scm.ScmFileStatus)19 ScmFileSet (org.apache.maven.scm.ScmFileSet)17 InputStreamReader (java.io.InputStreamReader)16 ScmResult (org.apache.maven.scm.ScmResult)15 StatusScmResult (org.apache.maven.scm.command.status.StatusScmResult)15 IOException (java.io.IOException)14 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)13 Matcher (java.util.regex.Matcher)11 AddScmResult (org.apache.maven.scm.command.add.AddScmResult)11 CheckOutScmResult (org.apache.maven.scm.command.checkout.CheckOutScmResult)10 UpdateScmResult (org.apache.maven.scm.command.update.UpdateScmResult)10 Commandline (org.codehaus.plexus.util.cli.Commandline)10 SynergyScmProviderRepository (org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository)9 FileInputStream (java.io.FileInputStream)8