How do I get all changed files for a Component using Java API?
I have managed to get a reference of the IWorkspaceConnection representing the Stream and a list of IComponentHandle representing the Components of the Streams. But how can I get the history of the Component and all changed files for each Change Set?
IWorkspaceManager workspaceManager = (IWorkspaceManager) repo.getClientLibrary(IWorkspaceManager.class);
IWorkspaceSearchCriteria wsSearchCriteria = WorkspaceSearchCriteria.FACTORY.newInstance();
wsSearchCriteria.setKind(IWorkspaceSearchCriteria.STREAMS);
wsSearchCriteria.setExactName("`123444"); // stream name
List<IWorkspaceHandle> workspaceHandles = workspaceManager.findWorkspaces(wsSearchCriteria, Integer.MAX_VALUE, monitor);
for (int i = 0; i < workspaceHandles.size(); i++) {
WorkspaceHandleImpl iWorkspaceHandle = (WorkspaceHandleImpl) workspaceHandles.get(i);
IWorkspaceConnection workspaceConnection = workspaceManager.getWorkspaceConnection(iWorkspaceHandle, monitor);
List<IComponentHandle> componentHandles = workspaceConnection.getComponents();
//what should I do here to get the history of the Component?
}
Accepted answer
IChangeHistory changeHistory = workspaceConnection.changeHistory(component)
IChangeHistory.recent() returns a list of IChangeHistoryEntryChange which gives you the change sets. The most recent change is at the end of the list, the start of the list is the oldest.
The history is split into "eras" whose size depends on the version of RTC and your usage patterns. Once you've looked at all the change sets in the recent list, use IChangeHistory.previousHistory to get the previous era in history. If previousHistory returns null, then you've reached the start of history.