/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/option.py

  • Committer: Jelmer Vernooij
  • Date: 2019-03-05 07:32:38 UTC
  • mto: (7290.1.21 work)
  • mto: This revision was merged to the branch mainline in revision 7311.
  • Revision ID: jelmer@jelmer.uk-20190305073238-zlqn981opwnqsmzi
Add appveyor configuration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
# TODO: For things like --diff-prefix, we want a way to customize the display
18
18
# of the option argument.
19
19
 
 
20
from __future__ import absolute_import
 
21
 
20
22
import optparse
21
23
import re
22
24
 
25
27
    registry as _mod_registry,
26
28
    revisionspec,
27
29
    )
 
30
from .sixish import (
 
31
    text_type,
 
32
    )
28
33
 
29
34
 
30
35
class BadOptionValue(errors.BzrError):
106
111
    >>> _parse_change_str('123..124')
107
112
    Traceback (most recent call last):
108
113
      ...
109
 
    breezy.errors.RangeInChangeOption: Option --change does not accept revision ranges
 
114
    RangeInChangeOption: Option --change does not accept revision ranges
110
115
    """
111
116
    revs = _parse_revision_str(revstr)
112
117
    if len(revs) > 1:
130
135
        type_list = '\n'.join(lines)
131
136
        msg = "No known merge type %s. Supported types are:\n%s" %\
132
137
            (typestring, type_list)
133
 
        raise errors.CommandError(msg)
 
138
        raise errors.BzrCommandError(msg)
134
139
 
135
140
 
136
141
class Option(object):
241
246
            self.custom_callback(option, self._param_name, bool_v, parser)
242
247
 
243
248
    def _optparse_callback(self, option, opt, value, parser):
244
 
        try:
245
 
            v = self.type(value)
246
 
        except ValueError as e:
247
 
            raise optparse.OptionValueError(
248
 
                'invalid value for option %s: %s' % (option, value))
 
249
        v = self.type(value)
249
250
        setattr(parser.values, self._param_name, v)
250
251
        if self.custom_callback is not None:
251
252
            self.custom_callback(option, self.name, v, parser)
455
456
        self.formatter = GettextIndentedHelpFormatter()
456
457
 
457
458
    def error(self, message):
458
 
        raise errors.CommandError(message)
 
459
        raise errors.BzrCommandError(message)
459
460
 
460
461
 
461
462
class GettextIndentedHelpFormatter(optparse.IndentedHelpFormatter):
559
560
               short_name='c',
560
561
               param_name='revision',
561
562
               help='Select changes introduced by the specified revision. See also "help revisionspec".')
562
 
_global_option('directory', short_name='d', type=str,
 
563
_global_option('directory', short_name='d', type=text_type,
563
564
               help='Branch to operate on, instead of working directory.')
564
 
_global_option('file', type=str, short_name='F')
 
565
_global_option('file', type=text_type, short_name='F')
565
566
_global_registry_option('log-format', "Use specified log format.",
566
567
                        lazy_registry=('breezy.log', 'log_formatter_registry'),
567
568
                        value_switches=True, title='Log format',
569
570
_global_registry_option('merge-type', 'Select a particular merge algorithm.',
570
571
                        lazy_registry=('breezy.merge', 'merge_type_registry'),
571
572
                        value_switches=True, title='Merge algorithm')
572
 
_global_option('message', type=str,
 
573
_global_option('message', type=text_type,
573
574
               short_name='m',
574
575
               help='Message string.')
575
576
_global_option('null', short_name='0',