#15 Support multiple SCMs properly this time

The previous version wasn't even close - repositories with the same branch names would clobber each other, and it would have origin/HEAD and origin/master for a single repository.

This is very similar to what was originally used before I started making a mess of things. Tested this time...