The assembly and merging history of supermassive black holes in hierarchical models of galaxy formation