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; }
// @Test @ClearCaseUniqueVobName(name = "interproject") @TestDescription( title = "JENKINS-18278", text = "When the foundation of a Stream has changed, the change set is miscalculated, because -pred selects the foundation baseline of the other Stream - interproject") public void jenkins18278() throws Exception { Stream source = ccenv.context.streams.get("one_int"); Stream target = ccenv.context.streams.get("two_int"); Component component = ccenv.context.components.get("_System"); /* Create first baseline on int and rebase dev */ ClearCaseRule.ContentCreator cc_target1 = ccenv .getContentCreator() .setBaselineName("bl-target-1") .setFilename("foo.bar") .setActivityName("target-act1") .setStreamName("two_int") .setPostFix("_two_int") .setNewElement(true) .create(); new Rebase(source).addBaseline(cc_target1.getBaseline()).rebase(true); /* Create first baseline on dev */ ClearCaseRule.ContentCreator cc_source1 = ccenv .getContentCreator() .setBaselineName("bl-source-1") .setFilename("foo.bar") .setActivityName("source-act1") .create(); /* Create baselines on int and rebase the last to dev */ ClearCaseRule.ContentCreator cc_target2 = ccenv .getContentCreator() .setBaselineName("bl-target-2") .setFilename("foo.bar") .setActivityName("target-act2") .setStreamName("two_int") .setPostFix("_two_int") .create(); ClearCaseRule.ContentCreator cc_target3 = ccenv .getContentCreator() .setBaselineName("bl-target-3") .setFilename("foo.bar") .setActivityName("target-act3") .setStreamName("two_int") .setPostFix("_two_int") .create(); ClearCaseRule.ContentCreator cc_target4 = ccenv .getContentCreator() .setBaselineName("bl-target-4") .setFilename("foo.bar") .setActivityName("target-act4") .setStreamName("two_int") .setPostFix("_two_int") .create(); new Rebase(source).addBaseline(cc_target4.getBaseline()).rebase(true); /* Create the last baseline on dev */ ClearCaseRule.ContentCreator cc_source2 = ccenv .getContentCreator() .setBaselineName("bl-source-2") .setFilename("foo.bar") .setActivityName("source-act2") .create(); /* Create the Jenkins project for the dev stream */ Project project = new CCUCMRule.ProjectCreator( "JENKINS-18278-interproject", "_System@" + ccenv.getPVob(), "one_int@" + ccenv.getPVob()) .getProject(); /* I need a first build */ jenkins.getProjectBuilder(project).build(); printDiffs(cc_source1.getBaseline(), cc_source2.getBaseline(), cc_source2.getPath()); printDiffs(cc_target4.getBaseline(), cc_source2.getBaseline(), cc_source2.getPath()); AbstractBuild build2 = jenkins.getProjectBuilder(project).build(); printChangeLog(build2); FilePath path = null; if (SystemUtils.IS_OS_WINDOWS) { path = new FilePath( project.getLastBuiltOn().getWorkspaceFor((FreeStyleProject) project), "view/" + ccenv.getUniqueName() + "/Model"); } else { path = new FilePath( project.getLastBuiltOn().getWorkspaceFor((FreeStyleProject) project), "view/vobs/" + ccenv.getUniqueName() + "/Model"); } listPath(path); List<Activity> activities = Version.getBaselineDiff( cc_source1.getBaseline(), cc_source2.getBaseline(), true, cc_source2.getPath()); new SystemValidator(build2) .validateBuild(Result.SUCCESS) .addActivitiesToCheck(activities) .validate(); }