Hunter Pence is under contract for 2013, as he still has arbitration eligibility, so it wasn't a guarantee that he'd be traded. Shane Victorino was a pending free agent, so he was almost certainly going to go, but Pence thought he might stick around.
The deal to the San Francisco Giants caught him by surprise, then, and here we have a video from Comcast SportsNet about the move.
The Astros traded for Pence at the deadline last year, and the 29-year-old outfielder had a career year as he helped the Phillies to the playoffs. He regressed to something closer to his career numbers, and with the possibility of a $14 million arbitration award in the offseason, the Phillies decided they'd rather have a package of Tommy Joseph, Nate Schierholtz, and Seth Rosin.