How to get IChangeSet from IVersionable ?
![]()
Yehiel Glass (255●3●89●86)
| asked Nov 04 '13, 8:44 a.m.
retagged Dec 16 '13, 4:01 p.m. by David Lafreniere (4.8k●7) 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
showing 5 of 7
show 2 more comments
|
Comments
Can you provide more context or a code sample? IVersionable has no notion of IChangeSet.
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 ?
} } }
Hi Tim,
I provided the code. Please replay.
Thanks,
Yehiel
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.
Thanks.
Do you have any idea how to get the history for each file in the changeset ?
Does someone knows how to get the file's history on deliver operation server side ?
Thanks!
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