'Tries to revert index code from copy.
It calls :py:meth:`.edit_index` with previous working.
:param string index_name: index name to restore'

def revert_index(self, index_name, reindex=False, ind_kwargs=None):

    ind_path = os.path.join(self.path, '_indexes')
    if (index_name in self.indexes_names):
        ind = self.indexes_names[index_name]
        full_name = ('%.2d%s.py' % (ind._order, index_name))
    else:
        indexes = os.listdir(ind_path)
        full_name = next((x for x in indexes if (x[2:(-3)] == index_name)))
    if (not full_name):
        raise DatabaseException(('%s    index    not    found' % index_name))
    last_path = os.path.join(ind_path, (full_name + '_last'))
    if (not os.path.exists(last_path)):
        raise DatabaseException(('No    previous    copy    found    for    %s' % index_name))
    correct_last_path = last_path[:(-5)]
    os.rename(last_path, correct_last_path)
    p = ('path:%s' % os.path.split(correct_last_path)[1])
    return self.edit_index(p, reindex, ind_kwargs)
