It's all about the answers!

Ask a question

How to get IVersionable 'history'


Boaz Nahum (1336) | asked Dec 03 '15, 3:28 a.m.
 Given IVersionable (or file/folder/symlink UUID)

How can I get its history in repository - I mean, all the change-sets in repository that contain this specific item.

It is like eclipse 'histroy in repository' just need the list of change-sets, no 'graph' like data structure is needed

Thanks

Boaz

Accepted answer


permanent link
Surya Tripathi (65017) | answered Dec 09 '15, 6:59 p.m.
You can try using this - 

ScmService->getHistoryForVersionable(ServiceHistoryProvider historyProvider, IVersionableHandle versionableHandle, int limit, boolean examineEras, ISynchronizationTimes[] syncTimes,IRepositoryProgressMonitorHandle monitor)

WorkspaceManager manager = (WorkspaceManager) SCMPlatform.getWorkspaceManager(repo);

IScmService service = manager.getServerConfigurationService();

ServiceHistoryProvider historyProvider = ServiceHistoryProvider.FACTORY.create((IWorkspaceHandle) workspace.getContextHandle(), componentHandle);

ChangeHistoryEntry[]  entries = service.getHistoryForVersionable(historyProvider, versionable, 100, true, null, null);
Boaz Nahum selected this answer as the correct answer

Comments
Boaz Nahum commented Dec 14 '15, 4:09 a.m.

 Thank you so much Surya


Your answer if very useful. Indeed I get the history entries, but my problem that I got only those in the specified repository workspace/stream.

Is there a way to get the entire file history - something like 'Show all in repository" in eclipse.


Boaz






Surya Tripathi commented Dec 15 '15, 1:27 p.m.

Sure.
Files belong to components. And, in order to get history of a file in component, you will need to provide a context - workspace or stream. A component can be included in more than one stream and these stream can have different set of changesets. Streams are a way to isolate changes of one team from another. When teams modify a file in a component, they are always modifying it in a context - in a workspace or in a stream. I dont think there is such a thing as 'show history in repository'. 


Surya Tripathi commented Dec 15 '15, 3:25 p.m. | edited Dec 15 '15, 3:27 p.m.

Well, yes, the Eclipse client has this feature 'show all in repository'.
I guess, you could query for all changesets in a component and get history in repository.
You can call ScmQueryService.findChangeSets() and set context for workspace as null to widen the scope to repository.
IVersionableHandle file;
IWorkspaceManager manager = SCMPlatform.getWorkspaceManager(repo);       
IChangeSetSearchCriteria criteria = IChangeSetSearchCriteria.FACTORY.newInstance();
criteria.setComponent(testComponent);
criteria.setOldestFirst(true);
//criteria.setContext(testWorkspace.getContextHandle());
if (file != null) {
      criteria.setItem(file);
}
List<IChangeSetHandle> changesets =  manager.findChangeSets(criteria, IWorkspaceManager.MAX_QUERY_SIZE, monitor);

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.