- I found that a simulation I was running in Simulink was giving me results that seemed to be wrong
- I was sure that previously it had given me the right results
- Therefore I wanted to "roll-back" to the previous version of that Simulink model
I thought this would be a simple and easy thing to do as I have all my files under version control. This sort of procedure is termed "reverting" in version control lingo. It was certainly possible, however it wasn't quite as easy as I expected, so I'll detail the process required.
As noted previously I'm using Bazaar for version control, through both the TortoiseBzr windows interface and also the Bazaar Explorer GUI. Bazaar supports several different methods of undoing mistakes. Through either method of accessing Bazaar you can get at a log of all the commits done on a certain file. From this window you have the option of either "Revert to this revision" or "Update to this revision". Either of these will give you the previous version (although the first one will not count the changes as committed); however they will give you whole of the repository at that revision. This might be useful for pulling out a whole set of software that works together, or establishing the state of an entire project at a particular point, but this is not what I needed.
It is possible to get at an individual file, but it involves a little bit more work. It may also be worth ensuring that the current version is committed in case you later decide that reverting was a mistake. Here is the process:
- Look at the log of file to determine what revision number contains the version you want (this is where having written good commit messages will help!)
- Make a note of the revision number that you require
- Highlight the address of the folder you are in and copy it
- Open a command line (on windows go to start - run... - "cmd")
- Change to the directory you require by typing "cd " and then pasting the folder address you copied before
- Type in the Bazaar revert command as follows:
num is the revision number that you require (as noted from the log)
file.ext is the filename and extension that you wish to revert to (this could be a list of files if you prefer)
This should give you the previous version of only that file. It will not be committed so you can check that it is the right version and make any changes you want before recommitting.