It's all about the answers!

Ask a question

understanding Afterstate and before for Merge Scenarios


vinitha dsouza (14719123) | asked Jun 14 '18, 7:00 a.m.
edited Jun 14 '18, 2:07 p.m. by David Lafreniere (4.8k7)

Dear Team,

- We have Merge scenario where a File A is Modified in Workspace A and same File A is deleted in another Workspace B  like mentioned in url: https://jazz.net/forum/questions/41298/understanding-an-ichange

For this VersionHandle is Null both for after state and before state. I Use RTC API but i pasting the XML Content on respective Changeset,

<changes><internalId>_bdu4MTYnEee4-awF8FM7vw</internalId><kind>0</kind><before xsi:nil="true"/><after xsi:nil="true"/><item itemId="_vuVo8OkrEeapv92fnweYFw" xsi:type="filesystem:FileItemHandle"/><merges><internalId>_bdu4MjYnEee4-awF8FM7vw</internalId><state>_LqAs6ekwEeaC67b_5u2DUQ</state><kind>16</kind></merges></changes>

Queries: Why kind of Change- 0?
If we are doing a sync tool from one SCM TO other/legacy system, what is correct way of handling for merge scenarios,
 Based on the Kind go ahead and do modify in legacy system or i have consider the Merge Changes related kind and handle?

Accepted answer


permanent link
David Lafreniere (4.8k7) | answered Jun 14 '18, 2:06 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
edited Jun 14 '18, 2:07 p.m.

A kind value of 0 (or "NONE") is a constant indicating the change has equivalent 'before' and 'after' states.

Both states can either be 'null', or both non-null (with the same state ID). For example, this may occur when a user resolves a conflict with "mine"; in this case the before state is the same as the afters state. The change set is relevant because it captures the fact that there was a merge (and records 'how' it was merged), but this change set will actually have 'no' change to the file in question if delivered for example.

The second question cannot easily be answered. If the other SCM allows you to record merge states, then you would need to consider the merge states in the change set. However if you are discarding all merge information, and if you are just trying to 'touch' a file based on an ordered series of change sets, then it would be reasonable to treat these change sets as a no-op.

vinitha dsouza selected this answer as the correct answer

Comments
vinitha dsouza commented Jun 15 '18, 1:38 a.m.

Thank you !!!
if i understand correctly then if Change.kind is NONE then this Changeset has No Update other than that there is some Merge Operation which triggered.
Both states can either be 'null', or both non-null (with the same state ID)
Question 1:One example when above said case occur
Both states can either be 'null'
One example when above said case occur
both non-null (with the same state ID). What is State ID we are talking about.
Question 2:We are currently use below snippet to get File
Object file = SCMPlatform.getWorkspaceManager(rtcTeamRepo)  .versionableManager().fetchCompleteState(versionableHandle,monitor);                                  
But unfortunately in above said cases, how do we get File Information?
my expectation is that we would like to log this information "File/Folder:FileName No Change done"


David Lafreniere commented Jun 15 '18, 10:02 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
-Files have both an itemID and a stateID. Both of these are UUIDS. In your snippet above, the file has an itemID of "_vuVo8OkrEeapv92fnweYFw", and one possible state of that file (a merge state in this case) is: "_LqAs6ekwEeaC67b_5u2DUQ". Think of the state of a file as the 'version' of a file. (Note: in the UI we show version IDs, or integers, to make it easier to read). A 'null' state means the file has been deleted.

-In the example, when both the before and after states are null in a change set, this can happen if for example I delete the file in my workspace and complete the change set. Then someone else delivers a content modification to that file and delivers it, after I accept it I will be in a conflict, and could choose to "Resolve with Mine"... basically discarding his content change, and keeping my deleted state. So that new change set would start in a deleted state, and end in a deleted state, and had a merge state which was non-null, but essentially was ignored.

David Lafreniere commented Jun 15 '18, 10:04 a.m.
FORUM MODERATOR / JAZZ DEVELOPER

-Having both states be non-null is more common than the deleted case. This happens if I make a change to a file and complete the change set. Someone else delivers a change and I accept it. I choose to "Resolve with Mine", which basically ignores the other persons change, and so in that new change set, nothing really happened to the file in the end.


David Lafreniere commented Jun 15 '18, 10:07 a.m.
FORUM MODERATOR / JAZZ DEVELOPER

If the before and after states are null, you may need to fetch the merge state (which would be non-null) to get a file object. This would allow you to get the name of the file.

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.