It's all about the answers!

Ask a question

How to get the Changesets linked to a particular snapshot ?

Jazzuser user (68950) | asked Jun 01 '17, 12:03 a.m.

Hello All,

I have a usecase wherein, given a snapshot as an input, I should get all the linked Changesets linked to it. Is there any way i can get the changeSet details ? Or what is the order in which i will get the changeSet details ?
What are the different ways of getting the changesets ?
Please advice.


Geoffrey Clemm commented Jun 01 '17, 12:24 a.m.

 To confirm, by "change sets linked to it", do you mean "the set of change sets that are in the history of the baselines that make up the snapshot"?

Logically, you would iterate through each baseline in the snapshot, and ask for the change set history of that baseline.    You can easily do this via the GUI, or are you looking for the API to do this?

Jazzuser user commented Jun 01 '17, 2:13 a.m.

Thanks a lot for the reply Geoffrey, Yes you are right, it is "the set of change sets that are in the history of the baselines that make up the snapshot:.
We are programmatically doing it, so we are looking for an API.
Is there any API to this ? could you please share sample code if any. This would help me alot.

Thank you.

Geoffrey Clemm commented Jun 01 '17, 3:02 p.m.

 I'll have to defer to others on the forum for the API pointers.   If using the command line is acceptable, I'd take a look at the scm command to see if it gives you what you need.

Accepted answer

permanent link
Arne Bister (2.6k12832) | answered Jun 01 '17, 4:11 p.m.
edited Jun 01 '17, 4:16 p.m.

Hello Jazzuser,

this is a sample of how to get the change sets:
I assume you already managed to obtain the snapshot as

IBaselineSet snapshot

Get list of baselines --> get change sets (need temp workspace to resolve history):
List<IChangeSetHandle> changesetList = new ArrayList<IChangeSetHandle();
IWorkspaceConnection tempWSConnection = SCMPlatform
                            name, comment, snapshot, null);
List<IBaseline> baselineList = snapshot.getBaselines();
for (IBaseline bl : baselineList {
IComponentHandle componentHandle = currentBL.getComponent(); IChangeHistory changeHistory;
changeHistory = tempWSConnection.changeHistory(componentHandle); List<IChangeHistoryDescriptor> csDescriptorList; csDescriptorList = changeHistory
.getHistoryDescriptors(Integer.MAX_VALUE, false, null);
for (IChangeHistoryDescriptor csDescriptor : csDescriptorList) {
List<IChangeHistoryEntryChange> csList = csDescriptor.recent();
for (final IChangeHistoryEntryChange currentEntry : csList) {
This way you get all change sets in snapshots baselines history but it can take a bit of time as this is a paging approach.

Please mark as accepted if this solves your task,
- Arne

Jazzuser user selected this answer as the correct answer

Jazzuser user commented Jun 08 '17, 4:28 a.m.

Hello Arne..
as per ur sample code, we created the temporary WorkSpace. but we need to delete the Workspace created after the execution of our logic.

Code for temp WS creation :
 IWorkspaceConnection wrkspaceCon=workspaceMgr.createWorkspace(scopeHandle, "testStreamDemoPurpose2", "forTestingpurpsose", snapShot, null);

we create the workspace the above way.
Is there any way to delete this IWorkspaceConnection object ?

Arne Bister commented Jun 18 '17, 7:34 a.m.

Try this:
                    workspaceHandle, null);

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.