Any alienation, that even by sale with the option of redemption or by exchange, made by the testator of all or part of the thing bequeathed, shall entail the revocation of the legacy for all that has been alienated, even if the subsequent alienation is null and void, and the object has reverted to the testator.