Revealing the mechanism of repressor inactivation during switching of a temperate bacteriophage