It's all about the answers!

Ask a question

Get last state history of an element


Fran Burgos (12312252) | asked Oct 26 '15, 10:55 a.m.
Iterating over a list of IChangeSets which have different IChanges. I would like to retrieve the last state of each element. For instance:

CS_1
|- File.1 (Add)
|- File.2 (Add)

CS_2
|- File.1 (Modify)
|- File.2 (Remove)

@return changes: [File.1 (from CS_2)]

for(IChangeSet changeSet : changeSets) {
    List<IChange> changes = (List<IChange>) changeSet.changes();
    for(IChange change : changes) {
// What else?
    }
}

Accepted answer


permanent link
Chris McGee (50511117) | answered Oct 27 '15, 10:37 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
Depending on where you get the change sets, it is possible for there to be more than one "latest" state. In your example above, it is pretty clear what the latest state is, however it gets more complicated if both change sets were created from the same state of the file. For example, if the change sets are retrieved from a work item then there is no guarantee that they build on each other.

Each IChange has a beforeState(), mergeStates() and afterState(). The afterState() will be the latest state in this context provided that all other IChanges for the versionable have afterState() that is in this IChange's beforeState() or in the mergeStates(). Otherwise, you don't know what that latest state is without additional information from a coherent history, such as from a stream or baseline.

I hope that this helps,
Chris
Fran Burgos selected this answer as the correct answer

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.