I'm still not clear on the root cause, but if test2wiki is used as the --wiki argument to mwscript mergeMessageFileList.php it will generate a different ExtensionMessages-<VERSION>.php file than the same script called with --wiki=mediawikiwiki
The php implementation of activeMWVersions returns the the first wiki listed in the wikiversions.json file because of the intrinsic behavior of iterating php arrays. For a typical group0 initial deploy this will return 1.XwmfY=mediawikiwiki as the version=wikidb pair for the new version.
The python implementation of the same script is not guaranteed to iterate the wikiversions.json file in any particular order. Cpython seems to iterate in a consistent order based on the interpreter version. On the production cluster this iteration order currently yields 1.XwmfY=test2wiki for the new version.
Version: wmf-deployment
Severity: blocker
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=51174