Using API, how to compare two baselines to get changesets
3 answers
Thanks for the help John. I was able to get both ways to work with your help. Here is some example code for reference.
Assuming baseline1 and baseline2 are provided IBaseline instances
Using IBaselineConnection (simpler):
Using IScmService.compareBaselines:
Assuming baseline1 and baseline2 are provided IBaseline instances
Using IBaselineConnection (simpler):
IBaselineConnection baselineConn = SCMPlatform.getWorkspaceManager(repo).getBaselineConnection(baseline1, monitor);
IChangeHistorySyncReport syncReport = baselineConn.compareTo(baseline2, monitor);
List<IChangeSetHandle> changeSets = syncReport.incomingChangeSets(); // or outgoing depending on order of baselines
Using IScmService.compareBaselines:
IScmService scmService = (IScmService) ((IClientLibraryContext)repo).getServiceInterface(IScmService.class);
IReference baseline1Ref = referenceFactory.createReferenceToItem(baseline1);
IReference baseline2Ref = referenceFactory.createReferenceToItem(baseline2);
IBaselineHandle baseline1Handle = (IBaselineHandle) baseline1Ref.resolve();
IBaselineHandle baseline2Handle = (IBaselineHandle) baseline2Ref.resolve();
IChangeHistorySyncReport syncReport = scmService.compareBaselines(baseline1Handle, baseline2Handle, null, null);
List<IChangeSetHandle> changeSets = syncReport.incomingChangeSets(); // or outgoing depending on order of baselines
I would also like to be to start with a build as an input to the baseline comparison. I found the example of how to query for a build and get a IBuildResult object. Can I use this to get at the baseline that the build created?
I need to get a list of changesets which are the changes between two baselines of a component. I see there is a BaselineComparison class, but have not found a way to use it. Some example code would be greatly appreciated. Thx!
I would also like to be to start with a build as an input to the baseline comparison. I found the example of how to query for a build and get a IBuildResult object. Can I use this to get at the baseline that the build created?
I need to get a list of changesets which are the changes between two baselines of a component. I see there is a BaselineComparison class, but have not found a way to use it. Some example code would be greatly appreciated. Thx!
BaselineComparison is in the repository model and despite its name, it does not have anything to do with Jazz Source Control baselines.
On the client-side, you can use IBaselineConnection#compareTo() to compare 2 baselines. On the server, you can use IScmService#compareBaselines(). Both return a sync-report which describes which change sets are unique to a particular baseline.
Builds are associated w/snapshots and snapshots contain multiple baselines ... so you would need to iterate throughout all common components and compare each component one at a time.
Hope this helps,
JohnC
SCM Server