Defer argparse registration to the last possible moment.
Review Request #3049 - Created Oct. 28, 2015 and submitted
Now option registration just records the registration args, and they get applied as needed, as an implementation detail. This was also an opportunity to clean up and de-complicate how we register recursive options, so the code is neater now. The performance benefits are very noticeable in profiles. Note that this means that some validation will only happen if the options are actually requested, which required a few changes in tests.
CI passes: https://travis-ci.org/pantsbuild/pants/builds/88011835
Status: Closed (submitted)
It seems like this will reregister options for every explicit scope in a command.
For each explicit scope, we'll relook up the default values for all flags set in that scope, as well as re normalizing.
Could we memoize the registration rather that recomputing the list of args and calling
Could we also lazily instantiate the argparser itself?
It's interesting that this is parent first, but recursive_option_registration_args is current, then parent.
I think it should be ordered parent first the whole way, rather than having the parents of the current scope first, but reversed. Is this ordering tested somewhere?
This seems like a new validation. If there isn't a test covering it, could you add one?
Should this check all the args? Registrations can register multiple flags. eg '--changes-since', '--parent', in what_changed.py