Search in sources :

Example 6 with ErrorStreamConsumer

use of org.apache.maven.scm.provider.tfs.command.consumer.ErrorStreamConsumer in project maven-scm by apache.

the class TfsAddCommand method executeAddCommand.

protected ScmResult executeAddCommand(ScmProviderRepository r, ScmFileSet f, String m, boolean b) throws ScmException {
    TfsCommand command = createCommand(r, f);
    FileListConsumer fileConsumer = new FileListConsumer();
    ErrorStreamConsumer err = new ErrorStreamConsumer();
    int status = command.execute(fileConsumer, err);
    if (status != 0 || err.hasBeenFed()) {
        return new AddScmResult(command.getCommandString(), "Error code for TFS add command - " + status, err.getOutput(), false);
    }
    return new AddScmResult(command.getCommandString(), fileConsumer.getFiles());
}
Also used : FileListConsumer(org.apache.maven.scm.provider.tfs.command.consumer.FileListConsumer) AddScmResult(org.apache.maven.scm.command.add.AddScmResult) ErrorStreamConsumer(org.apache.maven.scm.provider.tfs.command.consumer.ErrorStreamConsumer)

Example 7 with ErrorStreamConsumer

use of org.apache.maven.scm.provider.tfs.command.consumer.ErrorStreamConsumer in project maven-scm by apache.

the class TfsCheckOutCommand method createWorkspace.

private void createWorkspace(ScmProviderRepository r, ScmFileSet f, String workspace, String url) throws ScmException {
    ErrorStreamConsumer out = new ErrorStreamConsumer();
    ErrorStreamConsumer err = new ErrorStreamConsumer();
    // Checkout dir may not exist yet
    TfsCommand command = new TfsCommand("workspace", r, null, getLogger());
    command.addArgument("-new");
    command.addArgument("-comment:Creating workspace for maven command");
    command.addArgument("-server:" + url);
    command.addArgument(workspace);
    command.execute(out, err);
}
Also used : ErrorStreamConsumer(org.apache.maven.scm.provider.tfs.command.consumer.ErrorStreamConsumer)

Example 8 with ErrorStreamConsumer

use of org.apache.maven.scm.provider.tfs.command.consumer.ErrorStreamConsumer in project maven-scm by apache.

the class TfsCheckOutCommand method executeCheckOutCommand.

protected CheckOutScmResult executeCheckOutCommand(ScmProviderRepository r, ScmFileSet f, ScmVersion v, boolean recursive, boolean shallow) throws ScmException {
    TfsScmProviderRepository tfsRepo = (TfsScmProviderRepository) r;
    String url = tfsRepo.getServerPath();
    String tfsUrl = tfsRepo.getTfsUrl();
    String workspace = tfsRepo.getWorkspace();
    // Try creating workspace
    boolean workspaceProvided = workspace != null && !workspace.trim().equals("");
    if (workspaceProvided) {
        createWorkspace(r, f, workspace, tfsUrl);
    }
    TfsCommand command;
    int status;
    if (workspaceProvided) {
        status = executeUnmapCommand(r, f);
    }
    ErrorStreamConsumer out = new ErrorStreamConsumer();
    ErrorStreamConsumer err = new ErrorStreamConsumer();
    if (workspaceProvided) {
        command = new TfsCommand("workfold", r, null, getLogger());
        command.addArgument("-workspace:" + workspace);
        command.addArgument("-map");
        command.addArgument(url);
        command.addArgument(f.getBasedir().getAbsolutePath());
        status = command.execute(out, err);
        if (status != 0 || err.hasBeenFed()) {
            return new CheckOutScmResult(command.getCommandString(), "Error code for TFS checkout (workfold map) command - " + status, err.getOutput(), false);
        }
    }
    FileListConsumer fileConsumer = new FileListConsumer();
    err = new ErrorStreamConsumer();
    command = createGetCommand(r, f, v, recursive);
    status = command.execute(fileConsumer, err);
    if (status != 0 || err.hasBeenFed()) {
        return new CheckOutScmResult(command.getCommandString(), "Error code for TFS checkout (get) command - " + status, err.getOutput(), false);
    }
    return new CheckOutScmResult(command.getCommandString(), fileConsumer.getFiles());
}
Also used : FileListConsumer(org.apache.maven.scm.provider.tfs.command.consumer.FileListConsumer) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult) TfsScmProviderRepository(org.apache.maven.scm.provider.tfs.TfsScmProviderRepository) ErrorStreamConsumer(org.apache.maven.scm.provider.tfs.command.consumer.ErrorStreamConsumer)

Example 9 with ErrorStreamConsumer

use of org.apache.maven.scm.provider.tfs.command.consumer.ErrorStreamConsumer in project maven-scm by apache.

the class TfsEditCommand method executeEditCommand.

protected ScmResult executeEditCommand(ScmProviderRepository r, ScmFileSet f) throws ScmException {
    FileListConsumer out = new FileListConsumer();
    ErrorStreamConsumer err = new ErrorStreamConsumer();
    TfsCommand command = createCommand(r, f);
    int status = command.execute(out, err);
    if (status != 0 || err.hasBeenFed()) {
        return new EditScmResult(command.getCommandString(), "Error code for TFS edit command - " + status, err.getOutput(), false);
    }
    return new EditScmResult(command.getCommandString(), out.getFiles());
}
Also used : FileListConsumer(org.apache.maven.scm.provider.tfs.command.consumer.FileListConsumer) EditScmResult(org.apache.maven.scm.command.edit.EditScmResult) ErrorStreamConsumer(org.apache.maven.scm.provider.tfs.command.consumer.ErrorStreamConsumer)

Example 10 with ErrorStreamConsumer

use of org.apache.maven.scm.provider.tfs.command.consumer.ErrorStreamConsumer in project maven-scm by apache.

the class TfsStatusCommand method executeStatusCommand.

protected StatusScmResult executeStatusCommand(ScmProviderRepository r, ScmFileSet f) throws ScmException {
    TfsScmProviderRepository tfsRepo = (TfsScmProviderRepository) r;
    TfsCommand command = createCommand(tfsRepo, f);
    ChangedFileConsumer out = new ChangedFileConsumer(getLogger());
    ErrorStreamConsumer err = new ErrorStreamConsumer();
    int status = command.execute(out, err);
    if (status != 0 || err.hasBeenFed()) {
        return new StatusScmResult(command.getCommandString(), "Error code for TFS status command - " + status, err.getOutput(), false);
    }
    Iterator<ScmFile> iter = out.getChangedFiles().iterator();
    getLogger().debug("Iterating");
    while (iter.hasNext()) {
        ScmFile file = (ScmFile) iter.next();
        getLogger().debug(file.getPath() + ":" + file.getStatus());
    }
    return new StatusScmResult(command.getCommandString(), out.getChangedFiles());
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) TfsScmProviderRepository(org.apache.maven.scm.provider.tfs.TfsScmProviderRepository) ChangedFileConsumer(org.apache.maven.scm.provider.tfs.command.consumer.ChangedFileConsumer) ErrorStreamConsumer(org.apache.maven.scm.provider.tfs.command.consumer.ErrorStreamConsumer) ScmFile(org.apache.maven.scm.ScmFile)

Aggregations

ErrorStreamConsumer (org.apache.maven.scm.provider.tfs.command.consumer.ErrorStreamConsumer)13 FileListConsumer (org.apache.maven.scm.provider.tfs.command.consumer.FileListConsumer)7 ScmFile (org.apache.maven.scm.ScmFile)3 TfsScmProviderRepository (org.apache.maven.scm.provider.tfs.TfsScmProviderRepository)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 StringStreamConsumer (org.codehaus.plexus.util.cli.CommandLineUtils.StringStreamConsumer)2 ChangeSet (org.apache.maven.scm.ChangeSet)1 AddScmResult (org.apache.maven.scm.command.add.AddScmResult)1 BranchScmResult (org.apache.maven.scm.command.branch.BranchScmResult)1 ChangeLogScmResult (org.apache.maven.scm.command.changelog.ChangeLogScmResult)1 ChangeLogSet (org.apache.maven.scm.command.changelog.ChangeLogSet)1 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)1 CheckOutScmResult (org.apache.maven.scm.command.checkout.CheckOutScmResult)1 EditScmResult (org.apache.maven.scm.command.edit.EditScmResult)1 ListScmResult (org.apache.maven.scm.command.list.ListScmResult)1 StatusScmResult (org.apache.maven.scm.command.status.StatusScmResult)1 TagScmResult (org.apache.maven.scm.command.tag.TagScmResult)1 UnEditScmResult (org.apache.maven.scm.command.unedit.UnEditScmResult)1 UpdateScmResult (org.apache.maven.scm.command.update.UpdateScmResult)1