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

Get last state history of an element

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?
    }
}

0 votes


Accepted answer

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

0 votes

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,938
× 7,496

Question asked: Oct 26 '15, 10:55 a.m.

Question was seen: 2,354 times

Last updated: Oct 27 '15, 10:37 a.m.

Confirmation Cancel Confirm