It's all about the answers!

Ask a question

Reversing a work item with two change sets

Chris Barlock (18814738) | asked May 18 '16, 4:51 p.m.
retagged Aug 05 '16, 4:26 p.m. by Ken Tessier (84117)
I have delivered a change that I need to reverse.  The work item has two change sets.  If I show the component history, right-click the work item and Reverse, it allows me to create a patch for change set #2.  I resolved the changes and now have an unresolved change set in my Pending Changes view.  How do I do the same for change set #1.  I'm reluctant to go any further until I know the answer because I really don't want to deliver just a portion of the reversal.  I'm using RTC 5.0.2.


Accepted answer

permanent link
David Lafreniere (4.8k7) | answered May 23 '16, 9:15 p.m.
This is a variation of Arun's answer which was also correct.

If you want to reverse the changes from a work item you would:

1. Use the "Locate Change Sets" feature to first confirm that both change sets attached to the work item are delivered to the stream in question. If for some reason they are not, then there's nothing to do. To do this, right-click the work item, and select "Locate Change Sets", then in the "Search Targets" section at the bottom of the editor drag and drop the stream from another view into this Table section. This will let you know if all the change sets are delivered to the stream. Ex: if only CS1 is delivered and not CS2, then you can only reverse CS2.

2. Assuming both change sets are delivered. We would need to reverse each change set. It is important that we apply the reversal in the opposite order they were delivered. Thus we want to reverse CS2 first, and then CS1 (in some cases the order that the changes get applied in would make a difference). If you can't remember the order, you can always use the History view, and check the "Added On" column to see the dates.

3. Right-click on CS2 in the History view and select "Reverse". This will add a pending patch to the Pending Changes view. Now you can either try to 'auto-resolve' the changes if nothing conflicts, otherwise you will have to manually merge the changes. Whether it auto-resolves or if you manually merged the changes, it will appear as an unresolved pending change in the "Unresolved" folder. (This was part of your question I believe). You can now check-in the file changes into a new change set. To help you can also name this new change set "reversal of CS2". You can then deliver it to the stream.

4. With CS2 merged in (and no longer appearing as pending patch in the Pending Changes view) perform the same steps in #3 for CS1.

Now you have delivered two change sets which reversed CS1 and CS2 to the stream. You can associate these change sets to a 'reversal' Task work item to keep them together.

As a reference, here is the help doc for reversing a change set:

Note: There is another way to reverse changes. If in your case, CS1 and CS2 were the last change sets delivered to the stream, you could simply discard those two change sets from your repository workspace, and invoke the context menu action of "Replace in <target_stream>". This avoids creating/merging any patches. However if there are change sets delivered after CS1 and CS2 to the stream this approach will not work.

The above two suggestions are further explained here:
Michael Valenta selected this answer as the correct answer

2 other answers

permanent link
Arun K Sriramaiah (3.2k12977) | answered May 20 '16, 9:30 a.m.
Hi Chris,

I think both changes ( change set #1 and Change set#2 ) associated with work items both has to be reverted ( Reverse ) back if the changes are different.

1) Right Click and Reverse Change Set#1
2) Do same with Reverse Change Set#2

3) Resolve the conflict and merge it back to RWS with latest changes.
4) It will create new change set & verify new changes in latest change set  and associate Work-item before you deliver to Stream.

Please find the link below and test in test stream  before you do it on your production stream.

Let me know do you have any questions.


Chris Barlock commented May 20 '16, 10:02 a.m.

When I displayed the history and expanded the work Item, only the second change set was displayed.  However, since I needed to get this fixed, I ended up reversing the changes manually.

Arun K Sriramaiah commented May 20 '16, 10:26 a.m.

If that is the case I think the changeset has associated with different workitem.

permanent link
Geoffrey Clemm (30.1k33035) | answered Jun 05 '16, 5:59 p.m.
In the component history view, you should be able to just multi-select all of the change sets that you want to reverse, and then apply the reverse operation, which should create a patch that reverses all of those change sets.  

Your answer

Register or to post your answer.