Hamels pitches Phils past Pirates 7-2