[MERGE] Re: [api breakage] alias merge regression.

John A Meinel john at arbash-meinel.com
Tue Feb 28 04:16:37 GMT 2006


Robert Collins wrote:
> On Mon, 2006-02-27 at 21:43 -0600, John A Meinel wrote:
>> Robert Collins wrote:
>>> The alias merge broke the 0.7 run_argv for plugin commands.
>>>
>>> Just a heads up, I'm going to prepare a bugfix for this, it should be
>>> trivial to provide compatibility.
>>>
>>> Rob
>>>
>> I think we just need to define 'alias_argv=[]' or 'alias_argv=None' as
>> the default.
>>
>> I thought about it after it got merged. And then promptly forgot. :)
>> Thanks for noticing and remembering.
> 
> Its quite easy when it makes bzrtools blow up ;).
> 
> And its deeper than that: a plugin command that defines run_argv only
> has the two signature form.
> 
> We could define a replacement method - run_argv_aliases, and delegate
> run_argv to that but that means that plugins that define run_argv will
> have their code not executed. So we also need to detect when an old
> run_argv exists and if it exists run it instead:
> 
> 
> 
> 
> === modified file 'bzrlib/commands.py'
> --- bzrlib/commands.py
> +++ bzrlib/commands.py
> @@ -34,15 +34,16 @@
>  import errno
>  
>  import bzrlib
> -import bzrlib.trace
> -from bzrlib.trace import mutter, note, log_error, warning, be_quiet
>  from bzrlib.errors import (BzrError, 
>                             BzrCheckError,
>                             BzrCommandError,
>                             BzrOptionError,
>                             NotBranchError)
> +from bzrlib.option import Option
>  from bzrlib.revisionspec import RevisionSpec
> -from bzrlib.option import Option
> +from bzrlib.symbol_versioning import *
> +import bzrlib.trace
> +from bzrlib.trace import mutter, note, log_error, warning, be_quiet
>  
>  plugin_cmds = {}
>  
> @@ -207,8 +208,16 @@
>              r[o.name] = o
>          return r
>  
> -    def run_argv(self, argv, alias_argv=None):
> -        """Parse command line and run."""
> +    @deprecated_method(zero_eight)
> +    def run_argv(self, argv):
> +        """Parse command line and run.
> +        
> +        See run_argv_aliases for the 0.8 and beyond api.
> +        """
> +        return self.run_argv_aliases(argv)
> +
> +    def run_argv_aliases(self, argv, alias_argv=None):
> +        """Parse the command line and run with extra aliases in
> alias_argv."""
>          args, opts = parse_args(self, argv, alias_argv)
>          if 'help' in opts:  # e.g. bzr add --help
>              from bzrlib.help import help_on_command
> @@ -584,15 +593,21 @@
>      cmd = str(argv.pop(0))
>  
>      cmd_obj = get_cmd_object(cmd, plugins_override=not opt_builtin)
> +    if not getattr(cmd_obj.run_argv, 'is_deprecated', False):
> +        run = cmd_obj.run_argv
> +        run_argv = [argv]
> +    else:
> +        run = cmd_obj.run_argv_aliases
> +        run_argv = [argv, alias_argv]
>  
>      try:
>          if opt_lsprof:
> -            ret = apply_lsprofiled(opt_lsprof_file, cmd_obj.run_argv,
> argv, 
> -                                   alias_argv)
> +            ret = apply_lsprofiled(opt_lsprof_file, run, *run_argv)
>          elif opt_profile:
> -            ret = apply_profiled(cmd_obj.run_argv, argv, alias_argv)
> +            ret = apply_profiled(run, *run_argv)
>          else:
> -            ret = cmd_obj.run_argv(argv, alias_argv)
> +            ret = run(*run_argv)
>          return ret or 0
>      finally:
>          # reset, in case we may do other commands later within the same
> process
> 
> === modified file 'bzrlib/symbol_versioning.py'
> --- bzrlib/symbol_versioning.py 
> +++ bzrlib/symbol_versioning.py 
> @@ -139,3 +139,4 @@
>                          decorated_callable)
>      decorated_callable.__module__ = callable.__module__
>      decorated_callable.__name__ = callable.__name__
> +    decorated_callable.is_deprecated = True
> 
> === modified file 'bzrlib/tests/test_symbol_versioning.py'
> --- bzrlib/tests/test_symbol_versioning.py      
> +++ bzrlib/tests/test_symbol_versioning.py      
> @@ -87,6 +87,7 @@
>              self.assertEqualDiff(expected_docstring,
> deprecated_callable.__doc__)
>              self.assertEqualDiff(expected_name,
> deprecated_callable.__name__)
>              self.assertEqualDiff(expected_module,
> deprecated_callable.__module__)
> +            self.assertTrue(deprecated_callable.is_deprecated)
>          finally:
>              symbol_versioning.set_warning_method(old_warning_method)
>      

As long as the test suite still goes through run_argv_aliases (which it
should, since it uses run_bzr_catch_errors()) +1 from me.

John
=:->

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 249 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060227/0260ade8/attachment.pgp 


More information about the bazaar mailing list