It's all about the answers!

Ask a question

Using API, how to compare two baselines to get changesets


Jason Fregien (58910) | asked Sep 04 '09, 9:46 a.m.
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!

3 answers



permanent link
Jason Fregien (58910) | answered Sep 10 '09, 9:30 a.m.
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):

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

permanent link
Jason Fregien (58910) | answered Sep 08 '09, 3:44 p.m.
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!

permanent link
John Camelon (1.7k14) | answered Sep 08 '09, 3:49 p.m.
JAZZ DEVELOPER
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

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.