Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to get the Changesets linked to a particular snapshot ?

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.

Thanks.

0 votes

Comments

 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?

1 vote

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.

 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.

1 vote


Accepted answer

Permanent link

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
                    .getWorkspaceManager(teamRepository).createWorkspace(
                            currentUser,
                            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) {
changeSetList.add(currentEntry.changeSet());
}
}
}
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

0 votes

Comments

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 ?

Try this:
                SCMPlatform.getWorkspaceManager(teamRepository).deleteWorkspace(
                    workspaceHandle, null);

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,934
× 1,202
× 17

Question asked: Jun 01 '17, 12:03 a.m.

Question was seen: 2,830 times

Last updated: Jun 18 '17, 7:34 a.m.

Confirmation Cancel Confirm