How to revert a change properly

Hi folks,

Several days ago, I made a bad change in llvm, and I reverted it using following command

$ svn merge -r <bad change revision>:<previous revision>

However, this command seemed not working properly. I would like to know, what’s the right way to revert a bad change. I notice that there are some reverting change with proper message, e.g. “Revert: [some tag] commit message”. Shall I type this message manually? Or is there some useful tool that I could use?

Hi Xing:

There’s too much activity to automatically revert anything, so you need to commit a new change that effectively reverts the original patch – keeping in mind that someone else might have changed some of the same files, and/or lines, in the interim. Here’s how I do it.

Update your local master, and extract the change using svn diff or git diff to a patch file. Then use patch to apply it locally, using the ‘-R’ flag for reverse, and fix any merge conflicts. If your tests run clean, update your source one last time just in case, then commit with a new message indicating that you reverted it with a note on why, etc…

hth…
don

The “Revert [tag] message” is the default message generated by the ‘git revert’ command. Of course you would have to be using a git clone of LLVM instead of an SVN checkout in order to run ‘git revert’. This command is the equivalent of ‘svn merge –r’ run from the top-level directory. I believe svn commands will operate only on the directories below the current working directory, so I speculate that you ran the svn command from the lib subdirectory instead of from the top level, and thus missed the tests that were part of your original commit.

–paulr

Hi, Paul and Don

Thanks a lot, I haven’t change my version control tool from svn to git. I would like to have a try. Thanks a lot!

Regards,
Xing

<paul.robinson@sony.com> 於 2019年3月26日 週二 下午6:33 寫道:

Yes, thanks Paul. Out of the 9 or 10 I’ve used, git’s definitely the best.

In case you missed it, now there is git llvm revert : http://lists.llvm.org/pipermail/llvm-dev/2019-March/131395.html