turn (one's) coat
dated To change one's allegiance or affiliation (especially in politics) for personal gain or advantage. A good politician will espouse the most hard-line stance of his party's political ideologies, but a successful politician knows when to turn his coat.