/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-03-22 01:35:14 UTC
  • mfrom: (7490.7.6 work)
  • mto: This revision was merged to the branch mainline in revision 7499.
  • Revision ID: jelmer@jelmer.uk-20200322013514-7vw1ntwho04rcuj3
merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
from __future__ import absolute_import
18
 
 
19
17
# TODO: Define arguments by objects, rather than just using names.
20
18
# Those objects can specify the expected type of the argument, which
21
19
# would help with validation and shell completion.  They could also provide
23
21
 
24
22
# TODO: Specific "examples" property on commands for consistent formatting.
25
23
 
 
24
import contextlib
26
25
import os
27
26
import sys
28
27
 
38
37
 
39
38
import breezy
40
39
from breezy import (
41
 
    cleanup,
42
40
    cmdline,
43
41
    debug,
44
42
    trace,
52
50
from .option import Option
53
51
from .plugin import disable_plugins, load_plugins, plugin_name
54
52
from . import errors, registry
55
 
from .sixish import (
56
 
    string_types,
57
 
    )
58
53
 
59
54
 
60
55
class BzrOptionError(errors.BzrCommandError):
716
711
        r = Option.STD_OPTIONS.copy()
717
712
        std_names = set(r)
718
713
        for o in self.takes_options:
719
 
            if isinstance(o, string_types):
 
714
            if isinstance(o, str):
720
715
                o = option.Option.OPTIONS[o]
721
716
            r[o.name] = o
722
717
            if o.name in std_names:
783
778
            for hook in Command.hooks['pre_command']:
784
779
                hook(self)
785
780
            try:
786
 
                with cleanup.ExitStack() as self._exit_stack:
 
781
                with contextlib.ExitStack() as self._exit_stack:
787
782
                    return class_run(*args, **kwargs)
788
783
            finally:
789
784
                for hook in Command.hooks['post_command']:
1264
1259
    try:
1265
1260
        # ensure all arguments are unicode strings
1266
1261
        for a in argv:
1267
 
            if not isinstance(a, string_types):
 
1262
            if not isinstance(a, str):
1268
1263
                raise ValueError('not native str or unicode: %r' % (a,))
1269
 
            if isinstance(a, bytes):
1270
 
                # For Python 2 only allow ascii native strings
1271
 
                a = a.decode('ascii')
1272
1264
            new_argv.append(a)
1273
1265
    except (ValueError, UnicodeDecodeError):
1274
1266
        raise errors.BzrError("argv should be list of unicode strings.")