23/03/2012

Bazaar revert only one file to previous version

So this was the situation I was recently in:

  • 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:
  1. 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!)
  2. Make a note of the revision number that you require
  3. Highlight the address of the folder you are in and copy it
  4. Open a command line (on windows go to start - run... - "cmd")
  5. Change to the directory you require by typing "cd " and then pasting the folder address you copied before
  6. Type in the Bazaar revert command as follows:
bzr revert -r num file.ext
where:
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.



Matlab figures in Powerpoint

I've just been putting together a presentation in which I wanted to include a set of Matlab plots. Whilst there are plenty of ways to do this I thought I would detail the way I managed it...

I've mentioned before about maintaining quality by using vector graphics. Previously I've used .eps format for this, but I don't think it's well supported in Powerpoint (I did consider using alternative presentation software but I was pressed for time and this seemed like the easiest option). Instead I used .emf format which seems pretty well supported by Matlab. This is a Windows specific format so I can't say I'm particularly keen on it for general use, but it served a purpose here.

I saved my figures as separate images from Matlab and then imported into Powerpoint, but I think the same result can be achieved if you simply copy and paste between the two.

One of the benefits of having the plots in vector format is the ability to manipulate them within Powerpoint itself. For the unscrupulous this could be a good technique for "adjusting" a few points here and there to improve  your results - but obviously I didn't do that! What I did do was separate out several lines that were on the same plot, so that I could make them appear (using Powerpoint's animation features) gradually. This made the plots (which were a comparison of the results of several different simulations) much cleaner.

It was a little bit of a hassle to do this, but not awful, and I think worthwhile as it made the results much easier to present. When the .emf file is initially imported it is handled as an image; however, if you right click on it you will find that it can be "ungrouped". You might have to repeat this process a few times as the image seems to be built up of several sub-groups, but once you're done you'll find that individual lines are available to be manipulated. Unfortunately I then had to go through and "regroup" some of them manually to reform complete lines, which involved a bit of 'Ctrl' clicking - this was the tedious bit. I guess it depends how complicated the lines in your plots are as to how long this will take (and whether it is worthwhile or not).

Another benefit was being able to alter the font of my axes to match my presentation style. A trivial point perhaps, but it all goes to improve the overall appearance.

So to summarise:

  1. Copy figure in Matlab
  2. Paste in Powerpoint
  3. Right click and "ungroup"
  4. Repeat 3. until you get to a  level that you can manipulate the objects that you want
  5. You may find there are a few large white squares that form the background of the plot - these can be deleted (it will make things easier when you come to regrouping things in step 7.)
  6. 'ctrl'+'a' to select everything and then change the font to match your presentation
  7. 'ctrl' and click on objects to collect all the ones that should be in a group (you may need to zoom in on your slides to do this accurately)
  8. right click and "group" them
  9. move/recolour/animate/resize the objects as you desire to suit your presentation!

Hope that is of help to someone!?