Esempio n. 1
0
 /** If the attribute 'reconnectBetweenCommands' is true the connection is closed. */
 private void disconnect(Client client) {
   if (reconnectBetweenCommands) {
     try {
       client.getConnection().close();
     } catch (IOException e) {
       e.printStackTrace();
     }
   }
 }
Esempio n. 2
0
  @Override
  public void perform(final TaskListener listener)
      throws IOException, InterruptedException, CommandException, AuthenticationException {
    for (CvsRepository repository : revisionState.getModuleFiles().keySet()) {
      for (CvsFile file : revisionState.getModuleState(repository)) {
        AbstractCvs owner = parent.getParent();
        final Client cvsClient =
            owner.getCvsClient(repository, build.getEnvironment(listener), listener);
        final GlobalOptions globalOptions =
            owner.getGlobalOptions(repository, build.getEnvironment(listener));

        globalOptions.setCVSRoot(repository.getCvsRoot());

        RtagCommand rtagCommand = new RtagCommand();

        rtagCommand.setTag(tagName);
        rtagCommand.setTagByRevision(file.getRevision());
        rtagCommand.addModule(file.getName());
        rtagCommand.setMakeBranchTag(createBranch);
        rtagCommand.setOverrideExistingTag(moveTag);
        cvsClient
            .getEventManager()
            .addCVSListener(new BasicListener(listener.getLogger(), listener.getLogger()));

        try {
          cvsClient.executeCommand(rtagCommand, globalOptions);
        } catch (CommandAbortedException e) {
          e.printStackTrace(listener.error("The CVS rtag command was aborted"));
          throw e;
        } catch (CommandException e) {
          e.printStackTrace(listener.error("Error while trying to run CVS rtag command"));
          throw e;
        } catch (AuthenticationException e) {
          e.printStackTrace(
              listener.error("Authentication error while trying to run CVS rtag command"));
          throw e;
        } finally {
          try {
            cvsClient.getConnection().close();
          } catch (IOException ex) {
            listener.error("Could not close client connection: " + ex.getMessage());
          }
        }
      }
    }
  }