Search in sources :

Example 96 with ScmFile

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

the class StarteamCheckInConsumerTest method testParse.

public void testParse() throws Exception {
    File basedir = new File("/usr/scm-starteam/driver");
    StarteamCheckInConsumer consumer = new StarteamCheckInConsumer(new DefaultLog(), basedir);
    for (int i = 0; i < TEST_OUTPUT.length; ++i) {
        consumer.consumeLine(TEST_OUTPUT[i]);
    }
    Collection<ScmFile> entries = consumer.getCheckedInFiles();
    assertEquals("Wrong number of entries returned", 4, entries.size());
    ;
    for (ScmFile entry : entries) {
        assertTrue(entry.getPath().startsWith("./"));
        assertTrue(entry.getStatus() == ScmFileStatus.CHECKED_OUT);
    }
}
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)

Example 97 with ScmFile

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

the class StarteamCheckOutConsumerTest method testParse.

private void testParse(File basedir) throws Exception {
    StarteamCheckOutConsumer consumer = new StarteamCheckOutConsumer(new DefaultLog(), basedir);
    for (int i = 0; i < TEST_OUTPUT.length; ++i) {
        consumer.consumeLine(TEST_OUTPUT[i]);
    }
    Collection<ScmFile> entries = consumer.getCheckedOutFiles();
    assertEquals("Wrong number of entries returned", 9, entries.size());
    ;
    for (ScmFile entry : entries) {
        assertTrue(entry.getPath().startsWith("./"));
        assertTrue(entry.getStatus() == ScmFileStatus.CHECKED_OUT);
    }
}
Also used : DefaultLog(org.apache.maven.scm.log.DefaultLog) ScmFile(org.apache.maven.scm.ScmFile)

Example 98 with ScmFile

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

the class SynergyCheckInCommand method executeCheckInCommand.

/**
 * {@inheritDoc}
 */
protected CheckInScmResult executeCheckInCommand(ScmProviderRepository repository, ScmFileSet fileSet, String message, ScmVersion version) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing checkin command...");
    }
    SynergyScmProviderRepository repo = (SynergyScmProviderRepository) repository;
    if (getLogger().isDebugEnabled()) {
        getLogger().debug(fileSet.toString());
    }
    String ccmAddr = SynergyUtil.start(getLogger(), repo.getUser(), repo.getPassword(), null);
    try {
        SynergyTaskManager.getInstance().checkinDefaultTask(getLogger(), message, ccmAddr);
    } finally {
        SynergyUtil.stop(getLogger(), ccmAddr);
    }
    List<ScmFile> scmFiles = new ArrayList<ScmFile>(fileSet.getFileList().size());
    for (File f : fileSet.getFileList()) {
        scmFiles.add(new ScmFile(f.getPath(), ScmFileStatus.CHECKED_IN));
    }
    return new CheckInScmResult("ccm checkin", scmFiles);
}
Also used : SynergyScmProviderRepository(org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository) ArrayList(java.util.ArrayList) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) CheckInScmResult(org.apache.maven.scm.command.checkin.CheckInScmResult) ScmFile(org.apache.maven.scm.ScmFile)

Example 99 with ScmFile

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

the class AbstractUpdateCommand method executeCommand.

/**
 * {@inheritDoc}
 */
public ScmResult executeCommand(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
    ScmVersion scmVersion = parameters.getScmVersion(CommandParameter.SCM_VERSION, null);
    boolean runChangelog = Boolean.valueOf(parameters.getString(CommandParameter.RUN_CHANGELOG_WITH_UPDATE, "true")).booleanValue();
    UpdateScmResult updateScmResult = executeUpdateCommand(repository, fileSet, scmVersion);
    List<ScmFile> filesList = updateScmResult.getUpdatedFiles();
    if (!runChangelog) {
        return updateScmResult;
    }
    ChangeLogCommand changeLogCmd = getChangeLogCommand();
    if (filesList != null && filesList.size() > 0 && changeLogCmd != null) {
        ChangeLogScmResult changeLogScmResult = (ChangeLogScmResult) changeLogCmd.executeCommand(repository, fileSet, parameters);
        List<ChangeSet> changes = new ArrayList<ChangeSet>();
        ChangeLogSet changeLogSet = changeLogScmResult.getChangeLog();
        if (changeLogSet != null) {
            Date startDate = null;
            try {
                startDate = parameters.getDate(CommandParameter.START_DATE);
            } catch (ScmException e) {
            // Do nothing, startDate isn't define.
            }
            for (ChangeSet change : changeLogSet.getChangeSets()) {
                if (startDate != null && change.getDate() != null) {
                    if (startDate.after(change.getDate())) {
                        continue;
                    }
                }
                for (ScmFile currentFile : filesList) {
                    if (change.containsFilename(currentFile.getPath())) {
                        changes.add(change);
                        break;
                    }
                }
            }
        }
        updateScmResult.setChanges(changes);
    }
    return updateScmResult;
}
Also used : ScmException(org.apache.maven.scm.ScmException) ChangeLogSet(org.apache.maven.scm.command.changelog.ChangeLogSet) ArrayList(java.util.ArrayList) Date(java.util.Date) ScmVersion(org.apache.maven.scm.ScmVersion) ScmFile(org.apache.maven.scm.ScmFile) ChangeLogScmResult(org.apache.maven.scm.command.changelog.ChangeLogScmResult) ChangeLogCommand(org.apache.maven.scm.command.changelog.ChangeLogCommand) ChangeSet(org.apache.maven.scm.ChangeSet)

Example 100 with ScmFile

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

the class MavenScmCli method checkIn.

private void checkIn(ScmRepository scmRepository, File workingDirectory, ScmVersion version) throws ScmException {
    if (!workingDirectory.exists()) {
        System.err.println("The working directory doesn't exist: '" + workingDirectory.getAbsolutePath() + "'.");
        return;
    }
    String message = "";
    CheckInScmResult result = scmManager.checkIn(scmRepository, new ScmFileSet(workingDirectory), version, message);
    if (!result.isSuccess()) {
        showError(result);
        return;
    }
    List<ScmFile> checkedInFiles = result.getCheckedInFiles();
    System.out.println("Checked in these files: ");
    for (ScmFile file : checkedInFiles) {
        System.out.println(" " + file.getPath());
    }
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) CheckInScmResult(org.apache.maven.scm.command.checkin.CheckInScmResult) 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