Supporting configuration files in ~/.config/bazaar?
Vincent Ladeuil
v.ladeuil+lp at free.fr
Tue Nov 2 08:51:46 GMT 2010
>>>>> Neil Martinsen-Burrell <nmb at wartburg.edu> writes:
> I'm working on finishing off lp:~dobey/bzr/xdgconfigdir and bug
> #195397 (a fix has also been attempted in
> lp:~j-johan-edwards/bzr/xdg_basedir_compliance) which deals with
> storing configuration files in $XDG_CONFIG_DIR/bazaar on Unix
> (which is ~/.config/bazaar by default).
> I've outlined my thoughts in
> http://bazaar.launchpad.net/~nmb/bzr/xdgconfigdir/annotate/head:/doc/developers/xdg_config_spec.txt
> which are that we should essentially accept both ~/.bazaar and
> ~/.config/bazaar for now, but tell users that we suggest they use
> .config/bazaar (on Unix). lp:~nmb/bzr/xdgconfigdir has my
> attempts at fixing the bug. I plan to use that branch to
> continue with fixing up the docs, dealing with plugins and tests.
I think I'll go with an even more cautious transition plan:
* If $XDG_CONFIG_HOME exists, use it, additionally in this case if
~/.bazaar exists warn once (conditionally).
I haven't read the XDG spec but using $XDG_CONFIG_DIR for plugins sounds
fine to me.
Note that BZR_HOME defaults to ~/.bazaar/ so this should really be the
focus and all docs and help should only refer to it or to the 'bazaar
configuration directory'.
> I post to the list because although there is some discussion on
> bug #195397 about how and when we want to do this, I wanted to
> bring it up to the list before I wade in and change all of the
> docs.
> * Is this a change that Bazaar wants: ~/.bazaar -> ~/.config/bazaar?
Using the XDG spec sounds like the way to go in the long run.
One important point in this regard is that some users *will* use several
bzr versions at the same time which means we need to support *both*
directories existing.
So what if we plan the transition as:
* step 1:
ln -s ~/.bazaar ~/.config/bazaar
* step 2:
rm ~/.config/bazaar
mv ~/.bazaar ~/.config/bazaar
ln -s ~/.config/bazaar ~/.bazaar
* step 3:
rm ~/.bazaar
Which let the user control when doing which step is the most appropriate
and let us focus on updating the docs and all the plugins (also since
evrybody is supposed to use ``bzrlib.config.config_dir`` to obey
BZR_HOME, we should be fine there).
<snip/>
> * As a coding/layering issue, outputting a user-visible warning
> on every call to bzrlib.config.config_dir() leads to very ugly
> output: 5 or more messages for each command. Is there an easy
> way to output a message only once?
Look for Config.suppress_warnings... err, sorry :)
Given that accessing a local config file requires taking a lock which
itself requires getting the user name to put in the lock info file and
this user name is defined in a config file... we have already an
annoying issue there (with an existing XXX comment in _prepare_info).
But still, even with these caveats, this looks like a warning that the
user should be able to mute via the suppress_warnings configuration
option.
> I could see how to do this at the command level, but config_dir()
> has no sense of context and I'm not sure what the right way to add
> that context is. Warn once per day? Write a semaphore file
> somewhere in the configuration directory? I suspect that if I
> were truly a software developer then I would know the right way to
> do this, but alas I am not.
A static variable so that the warning is emmitted only once per bzrlib
loading seems the easiest way to go.
Vincent
More information about the bazaar
mailing list