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. Anh Tu Le selected this answer as the correct answer
Comments Thanks. I was able to get the changed files.But I ran into another problem. Whenever I get the changed files of a "Merge" change set, it always throws the following exception:
The IllegalArgumentException happens if one of the versionableHandles is null or not an instanceof IVersionableHandle.
I figured it out, one of the changed files had IChange.NONE kind. I edit my code to ignore all IChange.NONE files and the error does not occur anymore. Thanks for your help.
@Andrew, what does "The history is split into "eras" whose size depends on the version of RTC and your usage patterns" mean? My RTC has two release versions: 4.0.7 and 5.0.2. |
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.