'Inspect the repository changelog to reset metadata for all appropriate changeset revisions.
This method is called from both Galaxy and the Tool Shed.'

def reset_metadata_on_selected_repositories(self, **kwd):

    repository_ids = util.listify(kwd.get('repository_ids', None))
    message = ''
    status = 'done'
    if repository_ids:
        successful_count = 0
        unsuccessful_count = 0
        for repository_id in repository_ids:
            try:
                repository = repository_util.get_repository_in_tool_shed(self.app, repository_id)
                self.set_repository(repository)
                self.resetting_all_metadata_on_repository = True
                self.reset_all_metadata_on_repository_in_tool_shed()
                if self.invalid_file_tups:
                    message = tool_util.generate_message_for_invalid_tools(self.app, self.invalid_file_tups, repository, None, as_html=False)
                    log.debug(message)
                    unsuccessful_count += 1
                else:
                    log.debug(('Successfully    reset    metadata    on    repository    %s    owned    by    %s' % (str(repository.name), str(repository.user.username))))
                    successful_count += 1
            except:
                log.exception('Error    attempting    to    reset    metadata    on    repository    %s', str(repository.name))
                unsuccessful_count += 1
        message = ('Successfully    reset    metadata    on    %d    %s.        ' % (successful_count, inflector.cond_plural(successful_count, 'repository')))
        if unsuccessful_count:
            message += ('Error    setting    metadata    on    %d    %s    -    see    the    paster    log    for    details.        ' % (unsuccessful_count, inflector.cond_plural(unsuccessful_count, 'repository')))
    else:
        message = 'Select    at    least    one    repository    to    on    which    to    reset    all    metadata.'
        status = 'error'
    return (message, status)
