[MERGE] LRUCache changes

John Arbash Meinel john at arbash-meinel.com
Tue Dec 9 15:54:29 GMT 2008


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

Vincent Ladeuil wrote:
>>>>>> "jam" == John Arbash Meinel <john at arbash-meinel.com> writes:
> 
> <snip/>
>     jam> +    def __init__(self, max_cache=100, after_cleanup_count=None,
>     jam> +                 after_cleanup_size=symbol_versioning.DEPRECATED_PARAMETER):
>     jam> +        if symbol_versioning.deprecated_passed(after_cleanup_size):
>     jam> +            symbol_versioning.warn('LRUCache.__init__(after_cleanup_size) was'
>     jam> +                                   ' deprecated in 1.11. Use'
>     jam> +                                   ' after_cleanup_count instead.',
>     jam> +                                   DeprecationWarning)
> 
> 
> I know we don't have a deprecated_parameter() handy, but may be
> you can still use deprecated_in() and more importantly (1, 11) ?
> Or just define one_eleven and use it ?

It got really ugly, but I can do that. It looks something like:

'%s Use after_cleanup_count instead.' % (
  deprecated_in((1, 11)) % ('LRUCache.__init__(after_cleanup_size)'))

> 
> That will make future cleanups easier.

Are you sure that is better?

I can understand it is a little bit easier to grep for, but it really
isn't pretty code.

Part of the issue is that I want to point people in the direction of the
new parameter, which isn't directly supported with any of the
deprecation code.

> 
> Are you sure you want to use symbol_versioning.warn (which relies
> on 'from warnings import warn' in symbol_versioning) ?

Yes. That is

1) The standard way of issuing deprecation warnings
2) How we hook in "callDeprecated" in the test suite to override the
'symbol_versioning.warn()' function to record the call rather than
actually issuing the warning and causing PQM to fail the test because of
- -Werror.

Unfortunately, we expose the raw variable "warn" rather than having a
separate symbol_versioning.warn() function that then calls
warnings.warn. So if you did:
from bzrlib.symbol_versioning import warn

You won't be able to trap the deprecation warnings in the test suite.
(Similar to how bzrlib.ui.ui_factory is mutated at runtime/test time.)

John
=:->

> 
> BB: approve
> 
>     Vincent
> 

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

iEYEARECAAYFAkk+lLUACgkQJdeBCYSNAAOGCACfWqq/aTINS1Jsy/9pgfp1mf2w
sLQAn3DF2j5+qEd945din+9qdbqNMIt1
=wewI
-----END PGP SIGNATURE-----



More information about the bazaar mailing list