def run_():
    to_process = list(Document.objects.filter(
        ~Q(parent=None),
        current_revision__based_on=None,
        products__slug='thunderbird'))

    if len(to_process) == 0:
        print 'Nothing to do.'

    prog = Progress(len(to_process))

    for doc in to_process:
        prog.tick()
        oldest_parent_rev = (Revision.objects.filter(document=doc.parent)
                             .order_by('id')[0])

        # It has localizations, clearly it should be localizable.
        if not doc.parent.is_localizable:
            doc.parent.is_localizable = True
            doc.parent.save()

        doc.current_revision.based_on = oldest_parent_rev
        doc.current_revision.save()
dataset/ETHPy150Open mozilla/kitsune/scripts/fix_tb_basedon.py/run_/original