It's all about the answers!

Ask a question

How to get IChangeSet from IVersionable ?


0
1
Yehiel Glass (25528386) | asked Nov 04 '13, 8:44 a.m.
retagged Dec 16 '13, 4:01 p.m. by David Lafreniere (4.1k7)

Hello,

I have IVersionable (state of IChange) but need to have the last ChangeSet that changed this file.

How to get the IChangeSet out of it's IVersionable ?

Thanks,

Yehiel


Comments
Tim Mok commented Nov 04 '13, 8:55 a.m.
JAZZ DEVELOPER

Can you provide more context or a code sample? IVersionable has no notion of IChangeSet.


Yehiel Glass commented Nov 04 '13, 10:06 a.m. | edited Nov 07 '13, 8:58 a.m.

public class createApprovals extends AbstractService

implements IOperationParticipant {

public void run(AdvisableOperation operation,

IProcessConfigurationElement participantConfig,

IParticipantInfoCollector collector, IProgressMonitor monitor)

throws TeamRepositoryException {

Object operationData = operation.getOperationData();

final IWorkItemServer itemServer = getService(IWorkItemServer.class);

IRepositoryItemService itemService = getService(IRepositoryItemService.class);

IScmService scmService = getService(IScmService.class);

IProjectAreaHandle projectArea = operation.getProcessArea().getProjectArea();

DeliverOperationData data = (DeliverOperationData) operationData;

List<IChangeSetHandle> changeSetHandles = data.getChangeSetHandles();

int ArraySize = changeSetHandles.size();

IChangeSetHandle[] csArray = new IChangeSetHandle[ArraySize];;

IItemServiceIterator changeSetIterator = ItemServiceIteratorFactory.INSTANCE.createFetchItemsIterator(itemService, changeSetHandles.toArray(new IItemHandle[changeSetHandles.size()]), IRepositoryItemService.COMPLETE);

while (changeSetIterator.hasNext()) {

IChangeSet changeSet = (IChangeSet) changeSetIterator.next();

for (IChange change : (List<IChange>) changeSet.changes()) {

IVersionableHandle versionableHandle = null;

versionableHandle = change.afterState();

IVersionable item = (IVersionable) scmService.fetchState(

versionableHandle, null, null);

configProvider = ServiceConfigurationProvider.FACTORY.create(data.getDestWorkspace(),changeSet.getComponent());

//Here is the point I need help (I need to get the last IChangeSet for each change - and it's related workitem):

//I cheked some options:

//scmService.getHistoryForVersionable(historyProvider, versionableHandle, limit, examineEras, syncTimes, monitor)//Thats what I'm looking for, but problem:This method can only be called from outside of a transaction, or within a read transaction

//scmService.historyGetPredecessorState(provider, state, monitor) - Returns a versionable handle. How to get IChangeSet out of versionable handle ?

} } }


Yehiel Glass commented Nov 04 '13, 10:12 a.m.

Hi Tim,
I provided the code. Please replay.
Thanks,
Yehiel


Tim Mok commented Nov 07 '13, 9:14 a.m.
JAZZ DEVELOPER

I've converted your answer to a comment. In the future, provide the information about your question as part of the question so that others don't think that your question has already been answered.


Yehiel Glass commented Nov 07 '13, 9:41 a.m.

Thanks.
Do you have any idea how to get the history for each file in the changeset ?


Yehiel Glass commented Nov 10 '13, 4:01 a.m.

Does someone knows how to get the file's history on deliver operation server side ?
Thanks!


Chandan M B commented Jul 01 '15, 2:22 a.m. | edited Jul 05 '15, 2:36 p.m.

Hello Yehiel Glass
If you have got any solution for your question. Please paste the code.
I am in need of the same use case

Regards,
Chandan

showing 5 of 7 show 2 more comments

Be the first one to answer this question!


Register or to post your answer.