Ejemplo n.º 1
0
  private SnapshotView makeDeliverView(Stream stream, File workspace) throws ScmException {
    /* Replace evil characters with less evil characters */
    String newJobName = jobName.replaceAll("\\s", "_");

    viewtag =
        "CCUCM_" + newJobName + "_" + System.getenv("COMPUTERNAME") + "_" + stream.getShortname();

    File viewroot = new File(workspace, "view");

    return Util.makeView(stream, workspace, listener, loadModule, viewroot, viewtag);
  }
Ejemplo n.º 2
0
  public EstablishResult invoke(File workspace, VirtualChannel channel) throws IOException {

    out = listener.getLogger();

    logger = Logger.getLogger();

    StreamAppender app = null;
    if (pipe != null) {
      PrintStream toMaster = new PrintStream(pipe.getOut());
      app = new StreamAppender(toMaster);
      app.lockToCurrentThread();
      Logger.addAppender(app);
      app.setSettings(loggerSetting);
    } else if (pstream != null) {
      app = new StreamAppender(pstream);
      app.lockToCurrentThread();
      Logger.addAppender(app);
      app.setSettings(loggerSetting);
    }

    logger.debug("Starting remote deliver");

    this.workspace = workspace;

    /* Create the baseline object */
    Baseline baseline = null;
    try {
      baseline = Baseline.get(this.baseline).load();
    } catch (Exception e) {
      Logger.removeAppender(app);
      throw new IOException("Could not create Baseline object: " + e.getMessage(), e);
    }

    logger.debug(baseline + " created");

    /* Create the development stream object */
    /* Append vob to dev stream */

    Stream destinationStream = null;
    try {
      destinationStream = Stream.get(this.destinationstream).load();
    } catch (Exception e) {
      Logger.removeAppender(app);
      throw new IOException("Could not create destination Stream object: " + e.getMessage(), e);
    }

    logger.debug(destinationStream + " created");

    /* Make deliver view */
    try {
      snapview = makeDeliverView(destinationStream, workspace);
    } catch (Exception e) {
      Logger.removeAppender(app);
      throw new IOException("Could not create deliver view: " + e.getMessage(), e);
    }

    logger.debug("View: " + workspace);

    String diff = "";
    ClearCaseChangeset changeset = new ClearCaseChangeset();

    try {
      List<Activity> bldiff =
          Version.getBaselineDiff(destinationStream, baseline, true, snapview.getViewRoot());
      out.print(
          "["
              + Config.nameShort
              + "] Found "
              + bldiff.size()
              + " activit"
              + (bldiff.size() == 1 ? "y" : "ies")
              + ". ");

      int c = 0;
      for (Activity a : bldiff) {
        c += a.changeset.versions.size();
        for (Version version : a.changeset.versions) {
          changeset.addChange(version.getFullyQualifiedName(), version.getUser());
        }
      }
      out.println(c + " version" + (c == 1 ? "" : "s") + " involved");
      diff = Util.createChangelog(bldiff, baseline);
    } catch (Exception e1) {
      out.println("[" + Config.nameShort + "] Unable to create change log: " + e1.getMessage());
    }

    logger.debug("Changeset created");

    EstablishResult er = new EstablishResult(viewtag);
    er.setView(snapview);
    er.setMessage(diff);
    er.setChangeset(changeset);

    /* Make the deliver. Inline manipulation of er */
    deliver(baseline, destinationStream, er, forceDeliver, 2);

    /* End of deliver */
    Logger.removeAppender(app);
    return er;
  }