[merge] put back Option.short_name()

John Arbash Meinel john at arbash-meinel.com
Wed Jan 10 16:01:51 GMT 2007


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

Martin Pool wrote:
> On 10 Jan 2007, Alexander Belchenko <bialix at ukr.net> wrote:
> 
>>>>> The recent short option changes seemed to go in without a deprecation
>>>>> period. Was this intended? Was the SHORT_OPTIONS[] thing not meant for
>>>>> plugins to use?
>>>> These changes break bzrtools shell, for example, because
>>>> Option.short_name is no longer callable.  I think a deprecation period
>>>> would be appropriate, unless there are overriding concerns.
>>> OK, we can certainly set .short_name to be callable again -- I guess I
>>> will store the value in _short_name and make the method return that.
>>>
>>> To support SHORT_OPTIONS we might need a special object that stays in
>>> sync with the new stuff.  What did your plugin do with it, James?
>>>
>> short options changes also affects on bzr_man.rstx generator.
>> This was fixed recently and I add tests.
>> So changing them back to callable should trigger my tests.
> 
> Yes, I saw that.  It's good to have those tests, which would have helped
> me realize not to change it in the first place.
> 
> Anyhow, here is a bundle that at least restores the short_name() method
> to being callable and fixes the tests.  I would like to merge this for
> 0.14
> 
> I'm not sure how SHORT_OPTIONS should be deprecated -- if plugins are
> making arbitrary changes to it or registering new options it may be
> complicated.  I'm not going to add a complicated simulation of it until
> we know what is needed, but I'll try to fix any broken plugins.
> 

For "SHORT_OPTIONS" I think we can do what I did with
bzrlib.DEFAULT_IGNORES. Especially since the machinery is already there.

Just replace SHORT_OPTIONS with an object that handles __setitem__ or
something like that to give a deprecation warning, and then does
something like:

def __setitem__(self, key, value):
  symbol_versioning.warn()
  value._short_name = key


At least, that would be my feeling.

I also think that plugins might want the ability to do:

Option.OPTIONS['long-command-option'].set_short_name('l')


At least, I can see someone wanting to define an option that they use
all the time.

We almost have the functionality in ALIASES, but what you really want
there is a short-option expansion like popt has. IIRC, You can alias -X
=> --y --z --x=10 in something like ~/.popt_aliases

John
=:->


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

iD8DBQFFpQ3vJdeBCYSNAAMRAt2kAJ0efIqQUFFzHKi+m049W0Z7aqwvWgCfcvvF
IqfBaqlSkvvyVkI4M6er3Ac=
=ngS8
-----END PGP SIGNATURE-----



More information about the bazaar mailing list