Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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?

        }

0 votes


Accepted answer

Permanent link
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

0 votes

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:

Exception in thread "main" java.lang.IllegalArgumentException at com.ibm.team.scm.client.internal.ConnectionBasedClientConfigurationProxy.locateAncestors(ConnectionBasedClientConfigurationProxy.java:438) at com.ibm.team.scm.client.internal.ConnectionBasedClientConfigurationProxy.locateAncestors(ConnectionBasedClientConfigurationProxy.java:419)

Here is my code: List<iancestorreport> ancestorReports = configuration.locateAncestors(iVersionableHandles, monitor);

The IllegalArgumentException happens if one of the versionableHandles is null or not an instanceof IVersionableHandle.

ChangeSet.getChanges is a List<Change>.  Change.getItem() should be a non-null IVersionableHandle.  For a merge changeSet, Change.getMerges is a List<MergeState> and MergeState.getState() gives the merged in stateId, which may be null.  (null here represents a deleted file)

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

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,952
× 1,204

Question asked: Sep 24 '15, 10:15 p.m.

Question was seen: 3,629 times

Last updated: Aug 05 '18, 5:47 p.m.

Confirmation Cancel Confirm