> That's really nice, thanks.
>
> It would be nice if this could also check a variable in the global
> configuration, so that people can set it permanently in bazaar.conf. Some
> people may find that easier than getting an environment variable set,
> especially on windows or on remote machines. But, we could come back and do
> that later.
Even better would be to use only a config variable since env variables are not universal as you point out. In this precise case there (use encoding) I can't think of a use case where an env variable will be more appropriate.
> Doing it from config may cause some bootstrapping issues, as bzr
> needs to know the encoding pretty early on, probably before it loads any
> configuration.
I don't think so, config files are encoded in utf-8 only and cannot be encoded into anything else.
> That's really nice, thanks.
>
> It would be nice if this could also check a variable in the global
> configuration, so that people can set it permanently in bazaar.conf. Some
> people may find that easier than getting an environment variable set,
> especially on windows or on remote machines. But, we could come back and do
> that later.
Even better would be to use only a config variable since env variables are not universal as you point out. In this precise case there (use encoding) I can't think of a use case where an env variable will be more appropriate.
> Doing it from config may cause some bootstrapping issues, as bzr
> needs to know the encoding pretty early on, probably before it loads any
> configuration.
I don't think so, config files are encoded in utf-8 only and cannot be encoded into anything else.
63 + old_env = os.environ. get('BZR_ USER_ENCODING' ) set_or_ unset_env( 'BZR_USER_ ENCODING' , old_env) (cleanup)
64 + def cleanup():
65 + osutils.
66 + self.addCleanup
As mentioned by bialix, the idiom here should be:
self. overrideEnv( 'BZR_USER_ ENCODING' , <new value>)
But since osutils.get_user cache its result, this won't work reliably you also need:
self. overrideAttr( osutils, '_cached_ user_encoding' , None)
So anyway, better switch to config variables.