It's all about the answers!

Ask a question

Reversing a file deletion and keeping history

Marie Michelin (14417) | asked May 16 '18, 7:04 a.m.


(Using RTC 6.0.2).

One of our developers deleted files from a component and the change set was delivered in the stream.
Now we would like these files to come back into the component.
If I do a reverse from my repository workspace, applying the patch will create new files and we'll lose the previous history.
Is there any way to get the files back with their history ?

Thanks for your help,

Accepted answer

permanent link
Geoffrey Clemm (30.1k33035) | answered May 17 '18, 10:59 p.m.

When you use the "reverse" operation, you will keep all the history ... you will see a delete in the history, followed by the version resulting from the reverse.   (I have verified this in 6.0.5, but I don't believe this behavior has changed since 6.0.2). 

Marie Michelin selected this answer as the correct answer

Marie Michelin commented May 22 '18, 6:55 a.m. | edited May 26 '18, 9:20 p.m.

Thanks for your answer Geoffrey.
I should do something wrong with my reverse because it is not working well.
Here is what I do :
1- From my repository workspace, I show the history of the component
2- From the change set, I do the reverse operation
3- It creates the patch in the pending changes view
4- I would like to restore only some files that were deleted, so I select the ones I would like to restore, and select "resolve with proposed"
5- In the Pending Changes, new "unresolved" changes appears and when I check in, it is new files and not the one I had.

What did I do wrong ?

Thanks for your help,

Geoffrey Clemm commented May 26 '18, 9:23 p.m. | edited May 26 '18, 9:23 p.m.

 In step 4, instead of selecting the ones you want to restore, try deselecting the changes you don't want to undo, by applying the "remove from view" operation to them.   Then when all that is left is the files you want to restore, select the "auto-resolve" option.   When I do that, the "create" operation is just added to the existing history.

Marie Michelin commented May 28 '18, 10:24 a.m.

I'll try that but it will be really long, because it was a "cleaning" change set that removed a lot of filesn and only some of them need to be restored.
In fact, as it is not possible to select all the other files and remove them from the view, it will be a long job.
When I finish, I'll tell you if it is better.

Marie Michelin commented May 28 '18, 11:17 a.m.

I made the test (really long to remove all the changes I want to keep) and indeed it worked.
Is there any way to remove the files from the view more easily ?

Thanks for your help !

Geoffrey Clemm commented May 28 '18, 10:51 p.m. | edited May 28 '18, 10:52 p.m.

Glad to hear that it worked!   The fact that the first way you tried it didn't maintain history sounds like a bug to me, so I'd suggest filing a defect against RTC for it. 

Marie Michelin commented Jun 07 '18, 8:42 a.m.

Indeed I don't know exactly what I did that made the history lost, because I tried again with "resolve with proposed" only on the files I wanted to get back, and it worked.

Perhaps I tried with "auto resolve"...

Whatever, thanks for your help !

The only thing is that I need to select all the files in each directory. It could be long but it is better than removing the ones I don't want.

showing 5 of 6 show 1 more comments

One other answer

permanent link
Morten Madsen (3053250) | answered May 29 '18, 1:40 a.m.
Another way to do this is to do a "rollback".

1. Discard the change-sets from your history (the ones that delete the files)
2. Right-click the component (in pending changes) and select "Replace in <stream>". That will create a baseline and roll the stream to that baseline (the component without the change-sets that deletes the files).
3. After a rollback, make sure all developers accept the incoming "replace" or discard outgoing change-sets that they didn't create themselves.

This is a less "nice" operation than the one described above, but it is actually traceable in the most recent versions of RTC, because each stream now has an "Operations history", and you can actually rollback the rollback itself, if you decide it was not a good idea.

I would in most cases recommend the "reverse" option, because it is still rolling the stream "forward" and is traceable in history. But sometimes a rollback is necessary.


Marie Michelin commented Jun 07 '18, 4:47 a.m.

Thanks for your help Morten, but in this case, I can't do what you propose.

Indeed :
- I don't want to remove the whole change set, only some changes in it
- and there were a lot of change set delivered after this one.

I know that reverse is not traceable, but if the new change set is well named, it is understandable. Especially if I just put back the files that were deleted.

Thank you !

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.