[PATCH] Search user plugin directories before site plugin directories

John Arbash Meinel john at arbash-meinel.com
Fri Feb 23 16:48:46 GMT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

John Arbash Meinel wrote:
> Aaron Bentley wrote:
>>> John Arbash Meinel wrote:
>>>>> Aaron Bentley wrote:
>>>>>> Aaron Bentley has voted -1.
>>>>>> Status is now: Vetoed
>>>>>> Comment:
>>>>>> This is the wrong way to do it.  Plugins can override existing commands,
>>>>>> so user plugins should be searched last, so that they can override
>>>>>> commands supplied by system-wide plugins.
>>>>> You misunderstand how this code works. This is changing the python
>>>>> import path.
>>> If you think that's so, it's you who misunderstands.  This is
>>> determining the plugin path, not sys.path.
>>>
>>>>> And in the import path the *first* entry wins. Not the last
>>>>> one.
>>> This is the plugin path, not the import path, and so we get to determine
>>> how it works.  I think we should:
>>>
>>> 1. generate a list of all plugins
>>> 2. where there are name conflicts, choose the last-found plugin
>>> 3. load all plugins in the list.
>>>


That is how we used to do it. But it isn't true anymore. I just wanted
to make a quick note that I think when Robert updated the import code,
he actually broke our pre-existing behavior.

Try it yourself.

% echo "print 'local'" > ~/.bazaar/plugins/test.py
% echo "print 'site'" > bzr.dev/bzrlib/plugins/test.py
% bzr rocks
site
it sure does!

Now, I actually went back and created ~/.bazaar/test.py and a test.py in
every version of bzr since 0.8. And *all* of them load the site plugin
before they load the ~/.bazaar/plugins/test.py script.

And if you look at the old code, it did:
dirs = os.environ.get('BZR_PLUGIN_PATH',
                      DEFAULT_PLUGIN_PATH).split(os.pathsep)
dirs.insert(0, os.path.dirname(plugins.__file__))

So it also always inserted the site-wide plugins *before* the user's
plugins. (load_from_dirs() also always used the first one it found).

So the current behavior is compatible with history. Though I think we
can agree that it isn't the preferred behavior.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF3xruJdeBCYSNAAMRAhx3AKCZ+ht10LEOwg44f4zwak1kVYYJvACfV8/c
Vx0SWo479B4yQF9nsoN3LHc=
=Qpla
-----END PGP SIGNATURE-----



More information about the bazaar mailing list