rewrite of cleanup_repository script

The script is now better documented and has some informations about the
status of the repository along with some dry-run to let the user see
what actions will be performed if any.

references #2407
fixes #2222