nef: "Another option to consider is to not allow the upgrade while the unit is doing something the upgrade cant do."
For the lack of 100% reliable tools to speculate what action enablers would be active after the unit transformation, we probably can't go by nef's idea for the time being. At least in the stable branches we should just add cancelling of the illegal activities after unit has already transformed.
Noticed by Dino the Dinosore here. When a unit is auto-upgraded, it may continue its former activity even if its new type can't do it; though the activity is canceled if the situation is loaded from a savegame.
An obvious solution is placing an activity check into transform_unit() in server/unittools.c.