human
What is a the Python program you requested given the following:
Complete the below
def commit_on_success_unless_managed(using=None, savepoint=False):

    ''''Transitory API to preserve backwards-compatibility while refactoring.
    Once the legacy transaction management is fully deprecated, this should
    simply be replaced by atomic. Until then, it\'s necessary to guarantee that
    a commit occurs on exit, which atomic doesn\'t do when it\'s nested.
    Unlike atomic, savepoint defaults to False because that\'s closer to the
    legacy behavior.'
    '''
assistant
#Here is the Python program you requested.
    connection = get_connection(using)
    if (connection.get_autocommit() or connection.in_atomic_block):
        return atomic(using, savepoint)
    else:
        def entering(using):
            pass
        def exiting(exc_type, using):
            set_dirty(using=using)
        return _transaction_func(entering, exiting, using)