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

Replace components with active change-sets

 We are trying to programmatically create a new repository workspace even with components having active change-sets.
We use a stream as base seed workspace and a repository workspace to obtain the updated components (with active change-sets).
Our first code was:
IWorkspace newWks = scmService.createWorkspace(user, newWksName, newWksDescription, stream, null, stream, null, null, null).getWorkspace();
IComponentHandle[] components = scmService.getComponentsForWorkspace(stream, null);
final int n = components.length;
IComponentOpDescriptor[] ops = new IComponentOpDescriptor[n];
for (int i=0; i<n; i++) {
ops[i] = IComponentOpDescriptor.FACTORY.replaceComponent(components[i], wks, false);
}
scmService.updateComponents(newWks, null, ops, true, IScmService.DELTA_PER_INVOCATION, null, null);
but it throws an exception:
com.ibm.team.repository.common.TeamRepositoryException: Source change history era must not have active change sets
So, instead of replace components, we change our code to use drop & add components:
IComponentOpDescriptor[] dropOps = new IComponentOpDescriptor[n];
IComponentOpDescriptor[] addOps = new IComponentOpDescriptor[n];
for (int i=0; i<n; i++) {
dropOps[i] = IComponentOpDescriptor.FACTORY.dropComponent(components[i], false);
addOps[i] = IComponentOpDescriptor.FACTORY.addComponent(components[i], wks, false);
}
scmService.updateComponents(newWks, null, dropOps, true, IScmService.DELTA_PER_INVOCATION, null, null); scmService.updateComponents(newWks, null, addOps, true, IScmService.DELTA_PER_INVOCATION, null, null);
It seems odd, but now it works... :)
We cannot use only one array of ops because an exeception is throwned:
com.ibm.team.repository.common.TeamRepositoryException: Cannot have 2 operations on 1 component
In the new repository workspace, the active change-sets appear to belong to ADMIN instead of the original owner... Any advice?
Thanks in advance.

0 votes

Comments

Could you provide more information around this use case?  Why are components being replaced from the workspace once created?  Why are the change sets active?


Accepted answer

Permanent link
Those change sets are cloned because they cannot reference the same change sets from the seed workspace (active change sets can only exist in one workspace). The logged-in user will be the owner of the change sets.
David Lafreniere selected this answer as the correct answer

0 votes

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: Mar 28 '13, 4:43 a.m.

Question was seen: 4,859 times

Last updated: Aug 02 '16, 9:10 a.m.

Confirmation Cancel Confirm