/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/commands.py

  • Committer: Jelmer Vernooij
  • Date: 2020-02-07 02:14:30 UTC
  • mto: This revision was merged to the branch mainline in revision 7492.
  • Revision ID: jelmer@jelmer.uk-20200207021430-m49iq3x4x8xlib6x
Drop python2 support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
# TODO: Specific "examples" property on commands for consistent formatting.
25
25
 
 
26
import contextlib
26
27
import os
27
28
import sys
28
29
 
38
39
 
39
40
import breezy
40
41
from breezy import (
41
 
    cleanup,
42
42
    cmdline,
43
43
    debug,
44
44
    trace,
52
52
from .option import Option
53
53
from .plugin import disable_plugins, load_plugins, plugin_name
54
54
from . import errors, registry
55
 
from .sixish import (
56
 
    string_types,
57
 
    )
58
55
 
59
56
 
60
57
class BzrOptionError(errors.BzrCommandError):
716
713
        r = Option.STD_OPTIONS.copy()
717
714
        std_names = set(r)
718
715
        for o in self.takes_options:
719
 
            if isinstance(o, string_types):
 
716
            if isinstance(o, str):
720
717
                o = option.Option.OPTIONS[o]
721
718
            r[o.name] = o
722
719
            if o.name in std_names:
783
780
            for hook in Command.hooks['pre_command']:
784
781
                hook(self)
785
782
            try:
786
 
                with cleanup.ExitStack() as self._exit_stack:
 
783
                with contextlib.ExitStack() as self._exit_stack:
787
784
                    return class_run(*args, **kwargs)
788
785
            finally:
789
786
                for hook in Command.hooks['post_command']:
1260
1257
    try:
1261
1258
        # ensure all arguments are unicode strings
1262
1259
        for a in argv:
1263
 
            if not isinstance(a, string_types):
 
1260
            if not isinstance(a, str):
1264
1261
                raise ValueError('not native str or unicode: %r' % (a,))
1265
 
            if isinstance(a, bytes):
1266
 
                # For Python 2 only allow ascii native strings
1267
 
                a = a.decode('ascii')
1268
1262
            new_argv.append(a)
1269
1263
    except (ValueError, UnicodeDecodeError):
1270
1264
        raise errors.BzrError("argv should be list of unicode strings.")