Hm, yes. Means move some code around, because the order must be:
1) Split line
2) Strip args from front
3) Glob unquoted args
The unit tests for _command_line_to_argv aren't expecting step 2 so don't think you'll need to be looking at sys.argv there. You could change the tests, but it's good to have them reasonably isolated. Might be better to split the three steps into separate private functions and call 1 followed by 3 for those tests.
I don't think assigning to sys.argv will really help anything, there's only one entry point for this code already, it's just been poked too many times and become rather gnarly.
On the --profile-imports front, how about just removing the removal from from the bzr script and adding to bzrlib.commands.run_bzr something like:
elif a == '--profile-imports':
pass # already handled in startup script
Hm, yes. Means move some code around, because the order must be:
1) Split line
2) Strip args from front
3) Glob unquoted args
The unit tests for _command_ line_to_ argv aren't expecting step 2 so don't think you'll need to be looking at sys.argv there. You could change the tests, but it's good to have them reasonably isolated. Might be better to split the three steps into separate private functions and call 1 followed by 3 for those tests.
I don't think assigning to sys.argv will really help anything, there's only one entry point for this code already, it's just been poked too many times and become rather gnarly.
On the --profile-imports front, how about just removing the removal from from the bzr script and adding to bzrlib. commands. run_bzr something like: imports' :
elif a == '--profile-
pass # already handled in startup script