Example #1
0
  /**
   * Executes this command.
   *
   * @param client the client services object that provides any necessary services to this command,
   *     including the ability to actually process all the requests.
   */
  public void execute(ClientServices clientServices, EventManager eventManager)
      throws CommandException {
    this.clientServices = clientServices;
    try {
      clientServices.ensureConnection();

      super.execute(clientServices, eventManager);

      addArgumentRequest(isCheckThatUnedited(), "-c"); // NOI18N
      addArgumentRequest(isForceEvenIfEdited(), "-f"); // NOI18N

      // now add the request that indicates the working directory for the
      // command
      addRequestForWorkingDirectory(clientServices);
      addRequest(CommandRequest.NOOP);

      clientServices.processRequests(requests);
    } catch (AuthenticationException ex) {
      // TODO: handle case, where connection wasn't possible to establish
    } catch (CommandException ex) {
      throw ex;
    } catch (EOFException ex) {
      throw new CommandException(
          ex, CommandException.getLocalMessage("CommandException.EndOfFile", null)); // NOI18N
    } catch (Exception ex) {
      throw new CommandException(ex, ex.getLocalizedMessage());
    } finally {
      requests.clear();
      this.clientServices = null;
    }
  }
Example #2
0
  /**
   * Execute the command.
   *
   * @param client the client services object that provides any necessary services to this command,
   *     including the ability to actually process all the requests
   */
  @Override
  public void execute(ClientServices client, EventManager em)
      throws CommandException, AuthenticationException {
    client.ensureConnection();

    super.execute(client, em);

    try {
      // add arguments.
      if (isForceCommit()) {
        requests.add(1, new ArgumentRequest("-f")); // NOI18N
        if (isRecursive()) {
          requests.add(1, new ArgumentRequest("-R")); // NOI18N
        }
      }
      if (isNoModuleProgram()) {
        requests.add(1, new ArgumentRequest("-n")); // NOI18N
      }
      if (getToRevisionOrBranch() != null) {
        requests.add(1, new ArgumentRequest("-r")); // NOI18N
        requests.add(2, new ArgumentRequest(getToRevisionOrBranch()));
      }

      // build the message to send
      String message = getMessage();
      if (getLogMessageFromFile() != null) {
        message = loadLogFile(getLogMessageFromFile());
      }
      if (message != null) {
        message = message.trim();
      }
      if (message == null || message.length() == 0) {
        message = "no message"; // NOI18N
      }
      addMessageRequest(message);

      addRequestForWorkingDirectory(client);
      requests.addAll(argumentRequests);
      argumentRequests.clear(); // MK sanity check.
      addArgumentRequests();
      requests.add(CommandRequest.COMMIT);

      client.processRequests(requests);
    } catch (CommandException ex) {
      throw ex;
    } catch (Exception ex) {
      throw new CommandException(ex, ex.getLocalizedMessage());
    } finally {
      requests.clear();
    }
  }