Search in sources :

Example 46 with CLIOutputResponse

use of org.eclipse.che.plugin.svn.shared.CLIOutputResponse in project che by eclipse.

the class SubversionApi method status.

/**
     * Perform an "svn status" based on the request.
     *
     * @param request
     *         the request
     * @return the response
     * @throws IOException
     *         if there is a problem executing the command
     * @throws SubversionException
     *         if there is a Subversion issue
     */
public CLIOutputResponse status(final StatusRequest request) throws IOException, SubversionException, UnauthorizedException {
    final File projectPath = new File(request.getProjectPath());
    final List<String> cliArgs = defaultArgs();
    // Flags
    addFlag(cliArgs, "--ignore-externals", request.isIgnoreExternals());
    addFlag(cliArgs, "--no-ignore", request.isShowIgnored());
    addFlag(cliArgs, "--quiet", !request.isShowUnversioned());
    addFlag(cliArgs, "--show-updates", request.isShowUpdates());
    addFlag(cliArgs, "--verbose", request.isVerbose());
    // Options
    addOptionList(cliArgs, "--changelist", request.getChangeLists());
    addOption(cliArgs, "--depth", request.getDepth());
    // Command Name
    cliArgs.add("status");
    final CommandLineResult result = runCommand(null, cliArgs, projectPath, addWorkingCopyPathIfNecessary(request.getPaths()));
    return DtoFactory.getInstance().createDto(CLIOutputResponse.class).withCommand(result.getCommandLine().toString()).withOutput(result.getStdout()).withErrOutput(result.getStderr());
}
Also used : CommandLineResult(org.eclipse.che.plugin.svn.server.upstream.CommandLineResult) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) File(java.io.File)

Example 47 with CLIOutputResponse

use of org.eclipse.che.plugin.svn.shared.CLIOutputResponse in project che by eclipse.

the class SubversionApi method merge.

/**
     * Merges target with specified URL.
     *
     * @param request
     *         merge request
     * @return merge response
     * @throws IOException
     * @throws SubversionException
     */
public CLIOutputResponse merge(final MergeRequest request) throws IOException, SubversionException, UnauthorizedException {
    final File projectPath = new File(request.getProjectPath());
    final List<String> cliArgs = defaultArgs();
    // Command Name
    cliArgs.add("merge");
    cliArgs.add(request.getSourceURL());
    List<String> paths = new ArrayList<String>();
    paths.add(request.getTarget());
    final CommandLineResult result = runCommand(null, cliArgs, projectPath, paths);
    return DtoFactory.getInstance().createDto(CLIOutputResponse.class).withCommand(result.getCommandLine().toString()).withOutput(result.getStdout()).withErrOutput(result.getStderr());
}
Also used : CommandLineResult(org.eclipse.che.plugin.svn.server.upstream.CommandLineResult) ArrayList(java.util.ArrayList) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) File(java.io.File)

Example 48 with CLIOutputResponse

use of org.eclipse.che.plugin.svn.shared.CLIOutputResponse in project che by eclipse.

the class SubversionApiITest method testPropSet.

/**
     * Tests for {@link SubversionApi#propset(org.eclipse.che.plugin.svn.shared.PropertySetRequest)}.
     *
     * @throws Exception
     *         if anything goes wrong
     */
@Test
public void testPropSet() throws Exception {
    this.subversionApi.checkout(DtoFactory.getInstance().createDto(CheckoutRequest.class).withProjectPath(tmpAbsolutePath).withUrl(repoUrl));
    CLIOutputResponse response = this.subversionApi.propset(DtoFactory.getInstance().createDto(PropertySetRequest.class).withValue("'*.*'").withProjectPath(tmpAbsolutePath).withPath("trunk/A/B").withForce(true).withDepth(Depth.DIRS_ONLY).withName("svn:ignore"));
    assertEquals(response.getOutput().size(), 1);
    assertEquals(response.getOutput().get(0), "property 'svn:ignore' set on 'trunk" + File.separator + "A" + File.separator + "B'");
}
Also used : CheckoutRequest(org.eclipse.che.plugin.svn.shared.CheckoutRequest) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) PropertySetRequest(org.eclipse.che.plugin.svn.shared.PropertySetRequest) Test(org.junit.Test)

Example 49 with CLIOutputResponse

use of org.eclipse.che.plugin.svn.shared.CLIOutputResponse in project che by eclipse.

the class TestUtils method createGreekTreeRepository.

/**
     * Creates a new Subversion repository in a temporary location with the Greek Tree structure within it.
     *
     * @return the path to the repository root
     * @throws Exception
     *         if anything goes wrong
     */
public static File createGreekTreeRepository() throws Exception {
    final File repoRoot = Files.createTempDir();
    final File wcRoot = Files.createTempDir();
    // Clean up after execution
    repoRoot.deleteOnExit();
    wcRoot.deleteOnExit();
    // Create the repository
    final CommandLineResult result = UpstreamUtils.executeCommandLine(null, "svnadmin", new String[] { "create", repoRoot.getAbsolutePath() }, -1, repoRoot);
    // Make sure the result is fine
    handleCLIResult(result);
    // Checkout the repository
    final CLIOutputWithRevisionResponse coResponse = subversionApi.checkout(dtoFactory.createDto(CheckoutRequest.class).withProjectPath(wcRoot.getAbsolutePath()).withUrl("file:///" + repoRoot.getAbsolutePath()));
    assertTrue(coResponse.getRevision() > -1);
    final List<String> pathsToAdd = new ArrayList<>();
    // Create the directory structure
    for (final String path : GREEK_TREE) {
        final File fileForPath = new File(wcRoot, path);
        final String[] pathParts = path.split("/");
        // Create parent directories (Probably not necessary)
        Files.createParentDirs(fileForPath);
        if (!path.endsWith("/") && fileForPath.createNewFile()) {
            Files.write(("This is the file '" + pathParts[pathParts.length - 1] + "'.").getBytes(), fileForPath);
            pathsToAdd.add(path.substring(1));
        }
    }
    // Add the files in the working copy to version control
    subversionApi.add(dtoFactory.createDto(AddRequest.class).withProjectPath(wcRoot.getAbsolutePath()).withPaths(pathsToAdd).withAddParents(true));
    //Add properties
    final CLIOutputResponse propResponse = subversionApi.propset(dtoFactory.createDto(PropertySetRequest.class).withValue("user").withProjectPath(wcRoot.getAbsolutePath()).withPath(".").withForce(true).withDepth(Depth.FULLY_RECURSIVE).withName("owner"));
    assertTrue(propResponse.getOutput().size() > 0);
    // Commit the changes
    final CLIOutputWithRevisionResponse cResponse = subversionApi.commit(dtoFactory.createDto(CommitRequest.class).withProjectPath(wcRoot.getAbsolutePath()).withMessage("Initial commit."));
    assertEquals(1L, cResponse.getRevision());
    return repoRoot;
}
Also used : CommitRequest(org.eclipse.che.plugin.svn.shared.CommitRequest) CommandLineResult(org.eclipse.che.plugin.svn.server.upstream.CommandLineResult) ArrayList(java.util.ArrayList) CLIOutputWithRevisionResponse(org.eclipse.che.plugin.svn.shared.CLIOutputWithRevisionResponse) CheckoutRequest(org.eclipse.che.plugin.svn.shared.CheckoutRequest) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) PropertySetRequest(org.eclipse.che.plugin.svn.shared.PropertySetRequest) File(java.io.File)

Aggregations

CLIOutputResponse (org.eclipse.che.plugin.svn.shared.CLIOutputResponse)49 Operation (org.eclipse.che.api.promises.client.Operation)21 OperationException (org.eclipse.che.api.promises.client.OperationException)21 PromiseError (org.eclipse.che.api.promises.client.PromiseError)21 Project (org.eclipse.che.ide.api.resources.Project)18 File (java.io.File)14 Resource (org.eclipse.che.ide.api.resources.Resource)14 CommandLineResult (org.eclipse.che.plugin.svn.server.upstream.CommandLineResult)14 StatusNotification (org.eclipse.che.ide.api.notification.StatusNotification)7 Promise (org.eclipse.che.api.promises.client.Promise)6 Credentials (org.eclipse.che.ide.api.subversion.Credentials)6 ArrayList (java.util.ArrayList)5 CheckoutRequest (org.eclipse.che.plugin.svn.shared.CheckoutRequest)5 Test (org.junit.Test)4 Path (org.eclipse.che.ide.resource.Path)3 ListRequest (org.eclipse.che.plugin.svn.shared.ListRequest)3 PropertyListRequest (org.eclipse.che.plugin.svn.shared.PropertyListRequest)3 CLIOutputResponseList (org.eclipse.che.plugin.svn.shared.CLIOutputResponseList)2 Depth (org.eclipse.che.plugin.svn.shared.Depth)2 LockRequest (org.eclipse.che.plugin.svn.shared.LockRequest)2