To make the AI understand this and do it properly, we probably need to seperate the
CvUnit::getUpgradeCity function into two parts. Right now it searches for the best city to upgrade to a specific unit in, but only searching for the unit which that Civilization is able to create. In the case of the Tolerant Civs, we have to consider the fact that the upgrade will be to a different unit at each city (potentially), and thus need to run a function first to find out what upgrades are available for the unit and decide which one is the best. Then do a search for which cities that upgrade can happen in and go designate the best City for it.
That part is just for the AI, and might be a bit tricky.
For just being able to upgrade at different cities to UU upgrades, the vital function is
CvCity::canUpgrade. Kael already set this function to work properly in itself, but early in the function it calls out a few checks which also need cleaned up for it to work properly, since they make the same check Kael modified in this function redundantly.
In order for this to work though, you must also modify
CvPlayer::canTrain to loop over all cities the player owns if they are Tolerant and check for upgrade types there, and
CvPlot::canTrain needs modified so that it will check according to the building requirements of the City UBs instead of the Player's.
I've already done the CvPlot change and got that one working fine. And I wrote this up while checking why it didn't also solve the upgrade issue as notes for later. So if Kael doesn't beat me to it, and I don't forget about it, I'll post some working code later on which will allow you to upgrade units properly with the Tolerant Trait.
EDIT: Seems I was quite wrong about this approach. Modifications to the CvPlayer function resulted in being allowed to build all of the -1 Cost units/items. And didn't fix the upgrade issue
EDIT2: Annoying bit of code to deal with, quite a few twists and turns to track down. So far the best I have managed is to get it so you can still upgrade on your normal path while in the other cities, but that makes it so that you only need to have 1 building ANYWHERE to satisfy Building prereqs. And still failed to enable the Unique Unit upgrade. Overall, I think I am amused enough now to give it a serious go
