'Update a tool_shed_repository database record with new information retrieved from the
Tool Shed.  This happens when updating an installed repository to a new changeset revision.'

def update_repository_record(self, repository, updated_metadata_dict, updated_changeset_revision, updated_ctx_rev):

    repository.metadata = updated_metadata_dict
    tool_shed_url = common_util.get_tool_shed_url_from_tool_shed_registry(self.app, repository.tool_shed)
    suc.clean_dependency_relationships(self.app, updated_metadata_dict, repository, tool_shed_url)
    repository.changeset_revision = updated_changeset_revision
    repository.ctx_rev = updated_ctx_rev
    tool_shed_status_dict = repository_util.get_tool_shed_status_for_installed_repository(self.app, repository)
    if tool_shed_status_dict:
        repository.tool_shed_status = tool_shed_status_dict
    else:
        repository.tool_shed_status = None
    self.app.install_model.context.add(repository)
    self.app.install_model.context.flush()
    self.app.install_model.context.refresh(repository)
    return repository
