/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: 2017-06-10 12:50:32 UTC
  • mfrom: (6679 work)
  • mto: This revision was merged to the branch mainline in revision 6690.
  • Revision ID: jelmer@jelmer.uk-20170610125032-xb5rd5fjskjallos
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2005-2010 Canonical Ltd
 
2
#
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
 
7
#
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
#
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
16
 
 
17
# TODO: For things like --diff-prefix, we want a way to customize the display
 
18
# of the option argument.
 
19
 
 
20
from __future__ import absolute_import
 
21
 
 
22
import optparse
 
23
import re
 
24
 
 
25
from .lazy_import import lazy_import
 
26
lazy_import(globals(), """
 
27
from breezy import (
 
28
    errors,
 
29
    revisionspec,
 
30
    i18n,
 
31
    )
 
32
""")
 
33
 
 
34
from . import (
 
35
    registry as _mod_registry,
 
36
    )
 
37
from .sixish import (
 
38
    text_type,
 
39
    )
 
40
 
 
41
 
 
42
def _parse_revision_str(revstr):
 
43
    """This handles a revision string -> revno.
 
44
 
 
45
    This always returns a list.  The list will have one element for
 
46
    each revision specifier supplied.
 
47
 
 
48
    >>> _parse_revision_str('234')
 
49
    [<RevisionSpec_dwim 234>]
 
50
    >>> _parse_revision_str('234..567')
 
51
    [<RevisionSpec_dwim 234>, <RevisionSpec_dwim 567>]
 
52
    >>> _parse_revision_str('..')
 
53
    [<RevisionSpec None>, <RevisionSpec None>]
 
54
    >>> _parse_revision_str('..234')
 
55
    [<RevisionSpec None>, <RevisionSpec_dwim 234>]
 
56
    >>> _parse_revision_str('234..')
 
57
    [<RevisionSpec_dwim 234>, <RevisionSpec None>]
 
58
    >>> _parse_revision_str('234..456..789') # Maybe this should be an error
 
59
    [<RevisionSpec_dwim 234>, <RevisionSpec_dwim 456>, <RevisionSpec_dwim 789>]
 
60
    >>> _parse_revision_str('234....789') #Error ?
 
61
    [<RevisionSpec_dwim 234>, <RevisionSpec None>, <RevisionSpec_dwim 789>]
 
62
    >>> _parse_revision_str('revid:test@other.com-234234')
 
63
    [<RevisionSpec_revid revid:test@other.com-234234>]
 
64
    >>> _parse_revision_str('revid:test@other.com-234234..revid:test@other.com-234235')
 
65
    [<RevisionSpec_revid revid:test@other.com-234234>, <RevisionSpec_revid revid:test@other.com-234235>]
 
66
    >>> _parse_revision_str('revid:test@other.com-234234..23')
 
67
    [<RevisionSpec_revid revid:test@other.com-234234>, <RevisionSpec_dwim 23>]
 
68
    >>> _parse_revision_str('date:2005-04-12')
 
69
    [<RevisionSpec_date date:2005-04-12>]
 
70
    >>> _parse_revision_str('date:2005-04-12 12:24:33')
 
71
    [<RevisionSpec_date date:2005-04-12 12:24:33>]
 
72
    >>> _parse_revision_str('date:2005-04-12T12:24:33')
 
73
    [<RevisionSpec_date date:2005-04-12T12:24:33>]
 
74
    >>> _parse_revision_str('date:2005-04-12,12:24:33')
 
75
    [<RevisionSpec_date date:2005-04-12,12:24:33>]
 
76
    >>> _parse_revision_str('-5..23')
 
77
    [<RevisionSpec_dwim -5>, <RevisionSpec_dwim 23>]
 
78
    >>> _parse_revision_str('-5')
 
79
    [<RevisionSpec_dwim -5>]
 
80
    >>> _parse_revision_str('123a')
 
81
    [<RevisionSpec_dwim 123a>]
 
82
    >>> _parse_revision_str('abc')
 
83
    [<RevisionSpec_dwim abc>]
 
84
    >>> _parse_revision_str('branch:../branch2')
 
85
    [<RevisionSpec_branch branch:../branch2>]
 
86
    >>> _parse_revision_str('branch:../../branch2')
 
87
    [<RevisionSpec_branch branch:../../branch2>]
 
88
    >>> _parse_revision_str('branch:../../branch2..23')
 
89
    [<RevisionSpec_branch branch:../../branch2>, <RevisionSpec_dwim 23>]
 
90
    >>> _parse_revision_str('branch:..\\\\branch2')
 
91
    [<RevisionSpec_branch branch:..\\branch2>]
 
92
    >>> _parse_revision_str('branch:..\\\\..\\\\branch2..23')
 
93
    [<RevisionSpec_branch branch:..\\..\\branch2>, <RevisionSpec_dwim 23>]
 
94
    """
 
95
    # TODO: Maybe move this into revisionspec.py
 
96
    revs = []
 
97
    # split on .. that is not followed by a / or \
 
98
    sep = re.compile(r'\.\.(?![\\/])')
 
99
    for x in sep.split(revstr):
 
100
        revs.append(revisionspec.RevisionSpec.from_string(x or None))
 
101
    return revs
 
102
 
 
103
 
 
104
def _parse_change_str(revstr):
 
105
    """Parse the revision string and return a tuple with left-most
 
106
    parent of the revision.
 
107
 
 
108
    >>> _parse_change_str('123')
 
109
    (<RevisionSpec_before before:123>, <RevisionSpec_dwim 123>)
 
110
    >>> _parse_change_str('123..124')
 
111
    Traceback (most recent call last):
 
112
      ...
 
113
    RangeInChangeOption: Option --change does not accept revision ranges
 
114
    """
 
115
    revs = _parse_revision_str(revstr)
 
116
    if len(revs) > 1:
 
117
        raise errors.RangeInChangeOption()
 
118
    return (revisionspec.RevisionSpec.from_string('before:' + revstr),
 
119
            revs[0])
 
120
 
 
121
 
 
122
def _parse_merge_type(typestring):
 
123
    return get_merge_type(typestring)
 
124
 
 
125
def get_merge_type(typestring):
 
126
    """Attempt to find the merge class/factory associated with a string."""
 
127
    from merge import merge_types
 
128
    try:
 
129
        return merge_types[typestring][0]
 
130
    except KeyError:
 
131
        templ = '%s%%7s: %%s' % (' '*12)
 
132
        lines = [templ % (f[0], f[1][1]) for f in merge_types.items()]
 
133
        type_list = '\n'.join(lines)
 
134
        msg = "No known merge type %s. Supported types are:\n%s" %\
 
135
            (typestring, type_list)
 
136
        raise errors.BzrCommandError(msg)
 
137
 
 
138
 
 
139
class Option(object):
 
140
    """Description of a command line option
 
141
 
 
142
    :ivar _short_name: If this option has a single-letter name, this is it.
 
143
    Otherwise None.
 
144
    """
 
145
 
 
146
    # The dictionary of standard options. These are always legal.
 
147
    STD_OPTIONS = {}
 
148
 
 
149
    # The dictionary of commonly used options. these are only legal
 
150
    # if a command explicitly references them by name in the list
 
151
    # of supported options.
 
152
    OPTIONS = {}
 
153
 
 
154
    def __init__(self, name, help='', type=None, argname=None,
 
155
                 short_name=None, param_name=None, custom_callback=None,
 
156
                 hidden=False):
 
157
        """Make a new command option.
 
158
 
 
159
        :param name: regular name of the command, used in the double-dash
 
160
            form and also as the parameter to the command's run()
 
161
            method (unless param_name is specified).
 
162
 
 
163
        :param help: help message displayed in command help
 
164
 
 
165
        :param type: function called to parse the option argument, or
 
166
            None (default) if this option doesn't take an argument.
 
167
 
 
168
        :param argname: name of option argument, if any
 
169
 
 
170
        :param short_name: short option code for use with a single -, e.g.
 
171
            short_name="v" to enable parsing of -v.
 
172
 
 
173
        :param param_name: name of the parameter which will be passed to
 
174
            the command's run() method.
 
175
 
 
176
        :param custom_callback: a callback routine to be called after normal
 
177
            processing. The signature of the callback routine is
 
178
            (option, name, new_value, parser).
 
179
        :param hidden: If True, the option should be hidden in help and
 
180
            documentation.
 
181
        """
 
182
        self.name = name
 
183
        self.help = help
 
184
        self.type = type
 
185
        self._short_name = short_name
 
186
        if type is None:
 
187
            if argname:
 
188
                raise ValueError('argname not valid for booleans')
 
189
        elif argname is None:
 
190
            argname = 'ARG'
 
191
        self.argname = argname
 
192
        if param_name is None:
 
193
            self._param_name = self.name.replace('-', '_')
 
194
        else:
 
195
            self._param_name = param_name
 
196
        self.custom_callback = custom_callback
 
197
        self.hidden = hidden
 
198
 
 
199
    def short_name(self):
 
200
        if self._short_name:
 
201
            return self._short_name
 
202
 
 
203
    def set_short_name(self, short_name):
 
204
        self._short_name = short_name
 
205
 
 
206
    def get_negation_name(self):
 
207
        if self.name.startswith('no-'):
 
208
            return self.name[3:]
 
209
        else:
 
210
            return 'no-' + self.name
 
211
 
 
212
    def add_option(self, parser, short_name):
 
213
        """Add this option to an Optparse parser"""
 
214
        option_strings = ['--%s' % self.name]
 
215
        if short_name is not None:
 
216
            option_strings.append('-%s' % short_name)
 
217
        if self.hidden:
 
218
            help = optparse.SUPPRESS_HELP
 
219
        else:
 
220
            help = self.help
 
221
        optargfn = self.type
 
222
        if optargfn is None:
 
223
            parser.add_option(action='callback',
 
224
                              callback=self._optparse_bool_callback,
 
225
                              callback_args=(True,),
 
226
                              help=help,
 
227
                              *option_strings)
 
228
            negation_strings = ['--%s' % self.get_negation_name()]
 
229
            parser.add_option(action='callback',
 
230
                              callback=self._optparse_bool_callback,
 
231
                              callback_args=(False,),
 
232
                              help=optparse.SUPPRESS_HELP, *negation_strings)
 
233
        else:
 
234
            parser.add_option(action='callback',
 
235
                              callback=self._optparse_callback,
 
236
                              type='string', metavar=self.argname.upper(),
 
237
                              help=help,
 
238
                              default=OptionParser.DEFAULT_VALUE,
 
239
                              *option_strings)
 
240
 
 
241
    def _optparse_bool_callback(self, option, opt_str, value, parser, bool_v):
 
242
        setattr(parser.values, self._param_name, bool_v)
 
243
        if self.custom_callback is not None:
 
244
            self.custom_callback(option, self._param_name, bool_v, parser)
 
245
 
 
246
    def _optparse_callback(self, option, opt, value, parser):
 
247
        v = self.type(value)
 
248
        setattr(parser.values, self._param_name, v)
 
249
        if self.custom_callback is not None:
 
250
            self.custom_callback(option, self.name, v, parser)
 
251
 
 
252
    def iter_switches(self):
 
253
        """Iterate through the list of switches provided by the option
 
254
 
 
255
        :return: an iterator of (name, short_name, argname, help)
 
256
        """
 
257
        argname =  self.argname
 
258
        if argname is not None:
 
259
            argname = argname.upper()
 
260
        yield self.name, self.short_name(), argname, self.help
 
261
 
 
262
    def is_hidden(self, name):
 
263
        return self.hidden
 
264
 
 
265
 
 
266
class ListOption(Option):
 
267
    """Option used to provide a list of values.
 
268
 
 
269
    On the command line, arguments are specified by a repeated use of the
 
270
    option. '-' is a special argument that resets the list. For example,
 
271
      --foo=a --foo=b
 
272
    sets the value of the 'foo' option to ['a', 'b'], and
 
273
      --foo=a --foo=b --foo=- --foo=c
 
274
    sets the value of the 'foo' option to ['c'].
 
275
    """
 
276
 
 
277
    def add_option(self, parser, short_name):
 
278
        """Add this option to an Optparse parser."""
 
279
        option_strings = ['--%s' % self.name]
 
280
        if short_name is not None:
 
281
            option_strings.append('-%s' % short_name)
 
282
        parser.add_option(action='callback',
 
283
                          callback=self._optparse_callback,
 
284
                          type='string', metavar=self.argname.upper(),
 
285
                          help=self.help, dest=self._param_name, default=[],
 
286
                          *option_strings)
 
287
 
 
288
    def _optparse_callback(self, option, opt, value, parser):
 
289
        values = getattr(parser.values, self._param_name)
 
290
        if value == '-':
 
291
            del values[:]
 
292
        else:
 
293
            values.append(self.type(value))
 
294
        if self.custom_callback is not None:
 
295
            self.custom_callback(option, self._param_name, values, parser)
 
296
 
 
297
 
 
298
class RegistryOption(Option):
 
299
    """Option based on a registry
 
300
 
 
301
    The values for the options correspond to entries in the registry.  Input
 
302
    must be a registry key.  After validation, it is converted into an object
 
303
    using Registry.get or a caller-provided converter.
 
304
    """
 
305
 
 
306
    def validate_value(self, value):
 
307
        """Validate a value name"""
 
308
        if value not in self.registry:
 
309
            raise errors.BadOptionValue(self.name, value)
 
310
 
 
311
    def convert(self, value):
 
312
        """Convert a value name into an output type"""
 
313
        self.validate_value(value)
 
314
        if self.converter is None:
 
315
            return self.registry.get(value)
 
316
        else:
 
317
            return self.converter(value)
 
318
 
 
319
    def __init__(self, name, help, registry=None, converter=None,
 
320
        value_switches=False, title=None, enum_switch=True,
 
321
        lazy_registry=None, short_name=None, short_value_switches=None):
 
322
        """
 
323
        Constructor.
 
324
 
 
325
        :param name: The option name.
 
326
        :param help: Help for the option.
 
327
        :param registry: A Registry containing the values
 
328
        :param converter: Callable to invoke with the value name to produce
 
329
            the value.  If not supplied, self.registry.get is used.
 
330
        :param value_switches: If true, each possible value is assigned its
 
331
            own switch.  For example, instead of '--format knit',
 
332
            '--knit' can be used interchangeably.
 
333
        :param enum_switch: If true, a switch is provided with the option name,
 
334
            which takes a value.
 
335
        :param lazy_registry: A tuple of (module name, attribute name) for a
 
336
            registry to be lazily loaded.
 
337
        :param short_name: The short name for the enum switch, if any
 
338
        :param short_value_switches: A dict mapping values to short names
 
339
        """
 
340
        Option.__init__(self, name, help, type=self.convert,
 
341
                        short_name=short_name)
 
342
        self._registry = registry
 
343
        if registry is None:
 
344
            if lazy_registry is None:
 
345
                raise AssertionError(
 
346
                    'One of registry or lazy_registry must be given.')
 
347
            self._lazy_registry = _mod_registry._LazyObjectGetter(
 
348
                *lazy_registry)
 
349
        if registry is not None and lazy_registry is not None:
 
350
            raise AssertionError(
 
351
                'registry and lazy_registry are mutually exclusive')
 
352
        self.name = name
 
353
        self.converter = converter
 
354
        self.value_switches = value_switches
 
355
        self.enum_switch = enum_switch
 
356
        self.short_value_switches = short_value_switches
 
357
        self.title = title
 
358
        if self.title is None:
 
359
            self.title = name
 
360
 
 
361
    @property
 
362
    def registry(self):
 
363
        if self._registry is None:
 
364
            self._registry = self._lazy_registry.get_obj()
 
365
        return self._registry
 
366
 
 
367
    @staticmethod
 
368
    def from_kwargs(name_, help=None, title=None, value_switches=False,
 
369
                    enum_switch=True, **kwargs):
 
370
        """Convenience method to generate string-map registry options
 
371
 
 
372
        name, help, value_switches and enum_switch are passed to the
 
373
        RegistryOption constructor.  Any other keyword arguments are treated
 
374
        as values for the option, and their value is treated as the help.
 
375
        """
 
376
        reg = _mod_registry.Registry()
 
377
        for name, switch_help in sorted(kwargs.items()):
 
378
            name = name.replace('_', '-')
 
379
            reg.register(name, name, help=switch_help)
 
380
            if not value_switches:
 
381
                help = help + '  "' + name + '": ' + switch_help
 
382
                if not help.endswith("."):
 
383
                    help = help + "."
 
384
        return RegistryOption(name_, help, reg, title=title,
 
385
            value_switches=value_switches, enum_switch=enum_switch)
 
386
 
 
387
    def add_option(self, parser, short_name):
 
388
        """Add this option to an Optparse parser"""
 
389
        if self.value_switches:
 
390
            parser = parser.add_option_group(self.title)
 
391
        if self.enum_switch:
 
392
            Option.add_option(self, parser, short_name)
 
393
        if self.value_switches:
 
394
            for key in self.registry.keys():
 
395
                option_strings = ['--%s' % key]
 
396
                if self.is_hidden(key):
 
397
                    help = optparse.SUPPRESS_HELP
 
398
                else:
 
399
                    help = self.registry.get_help(key)
 
400
                if (self.short_value_switches and
 
401
                    key in self.short_value_switches):
 
402
                    option_strings.append('-%s' %
 
403
                                          self.short_value_switches[key])
 
404
                parser.add_option(action='callback',
 
405
                              callback=self._optparse_value_callback(key),
 
406
                                  help=help,
 
407
                                  *option_strings)
 
408
 
 
409
    def _optparse_value_callback(self, cb_value):
 
410
        def cb(option, opt, value, parser):
 
411
            v = self.type(cb_value)
 
412
            setattr(parser.values, self._param_name, v)
 
413
            if self.custom_callback is not None:
 
414
                self.custom_callback(option, self._param_name, v, parser)
 
415
        return cb
 
416
 
 
417
    def iter_switches(self):
 
418
        """Iterate through the list of switches provided by the option
 
419
 
 
420
        :return: an iterator of (name, short_name, argname, help)
 
421
        """
 
422
        for value in Option.iter_switches(self):
 
423
            yield value
 
424
        if self.value_switches:
 
425
            for key in sorted(self.registry.keys()):
 
426
                yield key, None, None, self.registry.get_help(key)
 
427
 
 
428
    def is_hidden(self, name):
 
429
        if name == self.name:
 
430
            return Option.is_hidden(self, name)
 
431
        return getattr(self.registry.get_info(name), 'hidden', False)
 
432
 
 
433
 
 
434
class OptionParser(optparse.OptionParser):
 
435
    """OptionParser that raises exceptions instead of exiting"""
 
436
 
 
437
    DEFAULT_VALUE = object()
 
438
 
 
439
    def __init__(self):
 
440
        optparse.OptionParser.__init__(self)
 
441
        self.formatter = GettextIndentedHelpFormatter()
 
442
 
 
443
    def error(self, message):
 
444
        raise errors.BzrCommandError(message)
 
445
 
 
446
 
 
447
class GettextIndentedHelpFormatter(optparse.IndentedHelpFormatter):
 
448
    """Adds gettext() call to format_option()"""
 
449
    def __init__(self):
 
450
        optparse.IndentedHelpFormatter.__init__(self)
 
451
 
 
452
    def format_option(self, option):
 
453
        """code taken from Python's optparse.py"""
 
454
        if option.help:
 
455
            option.help = i18n.gettext(option.help)
 
456
        return optparse.IndentedHelpFormatter.format_option(self, option)
 
457
 
 
458
 
 
459
def get_optparser(options):
 
460
    """Generate an optparse parser for breezy-style options"""
 
461
 
 
462
    parser = OptionParser()
 
463
    parser.remove_option('--help')
 
464
    for option in options.values():
 
465
        option.add_option(parser, option.short_name())
 
466
    return parser
 
467
 
 
468
 
 
469
def custom_help(name, help):
 
470
    """Clone a common option overriding the help."""
 
471
    import copy
 
472
    o = copy.copy(Option.OPTIONS[name])
 
473
    o.help = help
 
474
    return o
 
475
 
 
476
 
 
477
def _standard_option(name, **kwargs):
 
478
    """Register a standard option."""
 
479
    # All standard options are implicitly 'global' ones
 
480
    Option.STD_OPTIONS[name] = Option(name, **kwargs)
 
481
    Option.OPTIONS[name] = Option.STD_OPTIONS[name]
 
482
 
 
483
def _standard_list_option(name, **kwargs):
 
484
    """Register a standard option."""
 
485
    # All standard options are implicitly 'global' ones
 
486
    Option.STD_OPTIONS[name] = ListOption(name, **kwargs)
 
487
    Option.OPTIONS[name] = Option.STD_OPTIONS[name]
 
488
 
 
489
 
 
490
def _global_option(name, **kwargs):
 
491
    """Register a global option."""
 
492
    Option.OPTIONS[name] = Option(name, **kwargs)
 
493
 
 
494
 
 
495
def _global_registry_option(name, help, registry=None, **kwargs):
 
496
    Option.OPTIONS[name] = RegistryOption(name, help, registry, **kwargs)
 
497
 
 
498
 
 
499
# This is the verbosity level detected during command line parsing.
 
500
# Note that the final value is dependent on the order in which the
 
501
# various flags (verbose, quiet, no-verbose, no-quiet) are given.
 
502
# The final value will be one of the following:
 
503
#
 
504
# * -ve for quiet
 
505
# * 0 for normal
 
506
# * +ve for verbose
 
507
_verbosity_level = 0
 
508
 
 
509
 
 
510
def _verbosity_level_callback(option, opt_str, value, parser):
 
511
    global _verbosity_level
 
512
    if not value:
 
513
        # Either --no-verbose or --no-quiet was specified
 
514
        _verbosity_level = 0
 
515
    elif opt_str == "verbose":
 
516
        if _verbosity_level > 0:
 
517
            _verbosity_level += 1
 
518
        else:
 
519
            _verbosity_level = 1
 
520
    else:
 
521
        if _verbosity_level < 0:
 
522
            _verbosity_level -= 1
 
523
        else:
 
524
            _verbosity_level = -1
 
525
 
 
526
 
 
527
# Declare the standard options
 
528
_standard_option('help', short_name='h',
 
529
                 help='Show help message.')
 
530
_standard_option('quiet', short_name='q',
 
531
                 help="Only display errors and warnings.",
 
532
                 custom_callback=_verbosity_level_callback)
 
533
_standard_option('usage',
 
534
                 help='Show usage message and options.')
 
535
_standard_option('verbose', short_name='v',
 
536
                 help='Display more information.',
 
537
                 custom_callback=_verbosity_level_callback)
 
538
 
 
539
# Declare commonly used options
 
540
_global_option('change',
 
541
               type=_parse_change_str,
 
542
               short_name='c',
 
543
               param_name='revision',
 
544
               help='Select changes introduced by the specified revision. See also "help revisionspec".')
 
545
_global_option('directory', short_name='d', type=text_type,
 
546
               help='Branch to operate on, instead of working directory.')
 
547
_global_option('file', type=text_type, short_name='F')
 
548
_global_registry_option('log-format', "Use specified log format.",
 
549
                        lazy_registry=('breezy.log', 'log_formatter_registry'),
 
550
                        value_switches=True, title='Log format',
 
551
                        short_value_switches={'short': 'S'})
 
552
_global_registry_option('merge-type', 'Select a particular merge algorithm.',
 
553
                        lazy_registry=('breezy.merge', 'merge_type_registry'),
 
554
                        value_switches=True, title='Merge algorithm')
 
555
_global_option('message', type=text_type,
 
556
               short_name='m',
 
557
               help='Message string.')
 
558
_global_option('null', short_name='0',
 
559
                 help='Use an ASCII NUL (\\0) separator rather than '
 
560
                      'a newline.')
 
561
_global_option('overwrite', help='Ignore differences between branches and '
 
562
               'overwrite unconditionally.')
 
563
_global_option('remember', help='Remember the specified location as a'
 
564
               ' default.')
 
565
_global_option('reprocess', help='Reprocess to reduce spurious conflicts.')
 
566
_global_option('revision',
 
567
               type=_parse_revision_str,
 
568
               short_name='r',
 
569
               help='See "help revisionspec" for details.')
 
570
_global_option('show-ids',
 
571
               help='Show internal object ids.')
 
572
_global_option('timezone',
 
573
               type=str,
 
574
               help='Display timezone as local, original, or utc.')
 
575
 
 
576
diff_writer_registry = _mod_registry.Registry()
 
577
diff_writer_registry.register('plain', lambda x: x, 'Plaintext diff output.')
 
578
diff_writer_registry.default_key = 'plain'