The following snippet will let you limit number of post revisions in WordPress.