Exemplo n.º 1
0
  /**
   * Remove the files in an array of Files from the repository.
   *
   * @param files the files to remove.
   * @throws CommandException
   * @throws CommandAbortedException
   * @throws AuthenticationException
   * @throws InvalidCvsRootException
   */
  BasicServerResponse removeFromRepository(Client client, Collection files)
      throws CommandException, CommandAbortedException, AuthenticationException {
    BasicServerResponse basicServerResponse = new BasicServerResponse();

    if (files.size() < 1) {
      basicServerResponse.commandTerminated(null);
      return basicServerResponse;
    }

    setupConnection(client);
    // setupConnection();
    // Client client = getClient();

    RemoveCommand removeCommand = new RemoveCommand();
    removeCommand.setFiles(listToFileArray(files));

    client.getEventManager().addCVSListener(basicServerResponse);
    client.setLocalPath(projectPath.getAbsolutePath());

    printCommand(removeCommand, client);
    try {
      adminHandler.setMildManneredMode(true);
      client.executeCommand(removeCommand, globalOptions);
      basicServerResponse.waitForExecutionToFinish();
    } finally {
      client.getEventManager().removeCVSListener(basicServerResponse);
      disconnect(client);
      adminHandler.setMildManneredMode(false);
    }

    return basicServerResponse;
  }
Exemplo n.º 2
0
  /**
   * Import a project into the repository. The project will be put in the repository in a module
   * named after the project.
   *
   * @throws CommandException
   * @throws CommandAbortedException
   * @throws AuthenticationException
   * @throws InvalidCvsRootException
   */
  BasicServerResponse importInRepository(Client client)
      throws CommandException, CommandAbortedException, AuthenticationException {
    // setupConnection();
    // Client client = getClient();
    setupConnection(client);

    ImportCommand importCommand = new ImportCommand();

    // importCommand.addWrapper(localPath + "/TestProject/simplePackage/SimpleClass.java",
    // KeywordSubstitutionOptions.DEFAULT);
    // importCommand.addWrapper(localPath + "/TestProject/simplePackage/added.txt",
    // KeywordSubstitutionOptions.DEFAULT);
    importCommand.setModule(projectPath.getName());
    importCommand.setReleaseTag("init");
    importCommand.setLogMessage("logMessage");
    importCommand.setVendorTag("vendor");

    // Ignore all files during checkout. Then we can just commit them in-place.
    importCommand.addIgnoredFile("*");

    BasicServerResponse basicServerResponse = new BasicServerResponse();
    client.getEventManager().addCVSListener(basicServerResponse);
    client.setLocalPath(projectPath.getAbsolutePath());
    printCommand(importCommand, client);

    try {
      client.executeCommand(importCommand, globalOptions);
      basicServerResponse.waitForExecutionToFinish();
    } finally {
      client.getEventManager().removeCVSListener(basicServerResponse);
      disconnect(client);
    }

    return basicServerResponse;
  }
Exemplo n.º 3
0
  /**
   * Checkout project from repostitory to local project.
   *
   * @throws CommandException
   * @throws CommandAbortedException
   * @throws AuthenticationException
   * @throws InvalidCvsRootException
   */
  public synchronized BasicServerResponse doCheckout(Client client, File projectPath)
      throws AuthenticationException, CommandAbortedException, CommandException {
    // Client client = getClient();
    // setupConnection();
    setupConnection(client);

    CheckoutCommand checkoutCommand = new CheckoutCommand(true, projectPath.getName());
    checkoutCommand.setRecursive(true);
    checkoutCommand.setPruneDirectories(false);

    BasicServerResponse basicServerResponse = new BasicServerResponse();
    client.getEventManager().addCVSListener(basicServerResponse);
    client.setLocalPath(projectPath.getParent());

    printCommand(checkoutCommand, client);
    try {
      client.executeCommand(checkoutCommand, globalOptions);
      basicServerResponse.waitForExecutionToFinish();
    } finally {
      client.getEventManager().removeCVSListener(basicServerResponse);
      disconnect(client);
    }

    return basicServerResponse;
  }
Exemplo n.º 4
0
  /**
   * Add an array of Files/directories to the repository. Parent directories must be specified
   * before the sub-directories/files they contain.
   *
   * @param files the files to add
   * @param binary true if the added files should be treated as binary
   * @throws CommandException
   * @throws CommandAbortedException
   * @throws AuthenticationException
   * @throws InvalidCvsRootException
   */
  BasicServerResponse addToRepository(Client client, File[] files, boolean binary)
      throws CommandException, CommandAbortedException, AuthenticationException {
    BasicServerResponse basicServerResponse = new BasicServerResponse();

    // If there's nothing to add, return immediately
    if (files.length < 1) {
      basicServerResponse.commandTerminated(null);
      return basicServerResponse;
    }

    setupConnection(client);
    // setupConnection();
    // Client client = getClient();

    AddCommand addCommand = new AddCommand();
    addCommand.setFiles(files);

    KeywordSubstitutionOptions kso;
    if (binary) {
      kso = KeywordSubstitutionOptions.BINARY;
    } else {
      kso = KeywordSubstitutionOptions.DEFAULT;
    }
    addCommand.setKeywordSubst(kso);

    client.getEventManager().addCVSListener(basicServerResponse);
    client.setLocalPath(projectPath.toString());

    printCommand(addCommand, client);
    try {
      client.executeCommand(addCommand, globalOptions);
      basicServerResponse.waitForExecutionToFinish();
    } finally {
      client.getEventManager().removeCVSListener(basicServerResponse);
      disconnect(client);
    }

    return basicServerResponse;
  }