It's all about the answers!

Ask a question

RTC Client Java API: How do I get the state of the user's version before the merge from an IChange merge state?

Geoff Alexander (19623948) | asked Mar 18 '20, 3:16 p.m.
edited Mar 18 '20, 3:43 p.m.

I have an IChange instance, change, which I obtained from an IChangeSet instance, changeset, via a call to changeSet.changes().  I use change.mergeStates() to get a list of the change's merge states.  From the IChange.mergeStates Javadoc:

Consider this list to be the proposed versions that were merged with the before state. The after state is the versionable after the merge has been completed. The state of the user's version (mine) before the merge is not recorded in this IChange. It can be found in the IChange of the previous IChangeSet state.

How do I get the IChange of the previous IChangeSet state?  I tried calling changeSet.getMergePredecessorState() to get the the previous IChangeSet state.  However, it always returns null.

Accepted answer

permanent link
Andrew Niefer (7135) | answered Mar 24 '20, 1:37 p.m.
I believe that getMergePredecessorState will always be null for SCM items.

You want IChangeSet.getPredecessorState() (defined on IAuditable),
To fetch that previous state you will need to use IItemManager.fetchCompleteState rather than just fetchCompleteItem.

Geoff Alexander selected this answer as the correct answer

Geoff Alexander commented Mar 24 '20, 3:34 p.m.

Thanks for the response.  It was a misunderstanding on my part.  I finally realized that IChangeSet.getPredecessorState() gives the history of a single change set.

Andrew Niefer commented Apr 08 '20, 4:15 p.m.

Change sets can be reordered in history, and different workspaces/streams may have the same change sets in different orders.   So a given change set only captures transitions between file states, overall history is managed separately.

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.