Topo sort in validate to give nice cycle errors.
Topo sort in validate to give nice cycle errors.

(sapling split of e828f205b7434dd294bb95ee19488cd4df9cdf4e)
foursquare/fsqio,foursquare/fsqio,foursquare/fsqio,foursquare/fsqio,foursquare/fsqio