40
43
each revision specifier supplied.
42
45
>>> _parse_revision_str('234')
43
[<RevisionSpec_revno 234>]
46
[<RevisionSpec_dwim 234>]
44
47
>>> _parse_revision_str('234..567')
45
[<RevisionSpec_revno 234>, <RevisionSpec_revno 567>]
48
[<RevisionSpec_dwim 234>, <RevisionSpec_dwim 567>]
46
49
>>> _parse_revision_str('..')
47
50
[<RevisionSpec None>, <RevisionSpec None>]
48
51
>>> _parse_revision_str('..234')
49
[<RevisionSpec None>, <RevisionSpec_revno 234>]
52
[<RevisionSpec None>, <RevisionSpec_dwim 234>]
50
53
>>> _parse_revision_str('234..')
51
[<RevisionSpec_revno 234>, <RevisionSpec None>]
54
[<RevisionSpec_dwim 234>, <RevisionSpec None>]
52
55
>>> _parse_revision_str('234..456..789') # Maybe this should be an error
53
[<RevisionSpec_revno 234>, <RevisionSpec_revno 456>, <RevisionSpec_revno 789>]
56
[<RevisionSpec_dwim 234>, <RevisionSpec_dwim 456>, <RevisionSpec_dwim 789>]
54
57
>>> _parse_revision_str('234....789') #Error ?
55
[<RevisionSpec_revno 234>, <RevisionSpec None>, <RevisionSpec_revno 789>]
58
[<RevisionSpec_dwim 234>, <RevisionSpec None>, <RevisionSpec_dwim 789>]
56
59
>>> _parse_revision_str('revid:test@other.com-234234')
57
60
[<RevisionSpec_revid revid:test@other.com-234234>]
58
61
>>> _parse_revision_str('revid:test@other.com-234234..revid:test@other.com-234235')
59
62
[<RevisionSpec_revid revid:test@other.com-234234>, <RevisionSpec_revid revid:test@other.com-234235>]
60
63
>>> _parse_revision_str('revid:test@other.com-234234..23')
61
[<RevisionSpec_revid revid:test@other.com-234234>, <RevisionSpec_revno 23>]
64
[<RevisionSpec_revid revid:test@other.com-234234>, <RevisionSpec_dwim 23>]
62
65
>>> _parse_revision_str('date:2005-04-12')
63
66
[<RevisionSpec_date date:2005-04-12>]
64
67
>>> _parse_revision_str('date:2005-04-12 12:24:33')
68
71
>>> _parse_revision_str('date:2005-04-12,12:24:33')
69
72
[<RevisionSpec_date date:2005-04-12,12:24:33>]
70
73
>>> _parse_revision_str('-5..23')
71
[<RevisionSpec_revno -5>, <RevisionSpec_revno 23>]
74
[<RevisionSpec_dwim -5>, <RevisionSpec_dwim 23>]
72
75
>>> _parse_revision_str('-5')
73
[<RevisionSpec_revno -5>]
76
[<RevisionSpec_dwim -5>]
74
77
>>> _parse_revision_str('123a')
75
Traceback (most recent call last):
77
NoSuchRevisionSpec: No namespace registered for string: '123a'
78
[<RevisionSpec_dwim 123a>]
78
79
>>> _parse_revision_str('abc')
79
Traceback (most recent call last):
81
NoSuchRevisionSpec: No namespace registered for string: 'abc'
80
[<RevisionSpec_dwim abc>]
82
81
>>> _parse_revision_str('branch:../branch2')
83
82
[<RevisionSpec_branch branch:../branch2>]
84
83
>>> _parse_revision_str('branch:../../branch2')
85
84
[<RevisionSpec_branch branch:../../branch2>]
86
85
>>> _parse_revision_str('branch:../../branch2..23')
87
[<RevisionSpec_branch branch:../../branch2>, <RevisionSpec_revno 23>]
86
[<RevisionSpec_branch branch:../../branch2>, <RevisionSpec_dwim 23>]
88
87
>>> _parse_revision_str('branch:..\\\\branch2')
89
88
[<RevisionSpec_branch branch:..\\branch2>]
90
89
>>> _parse_revision_str('branch:..\\\\..\\\\branch2..23')
91
[<RevisionSpec_branch branch:..\\..\\branch2>, <RevisionSpec_revno 23>]
90
[<RevisionSpec_branch branch:..\\..\\branch2>, <RevisionSpec_dwim 23>]
93
92
# TODO: Maybe move this into revisionspec.py
321
329
'--knit' can be used interchangeably.
322
330
:param enum_switch: If true, a switch is provided with the option name,
323
331
which takes a value.
332
:param lazy_registry: A tuple of (module name, attribute name) for a
333
registry to be lazily loaded.
334
:param short_name: The short name for the enum switch, if any
335
:param short_value_switches: A dict mapping values to short names
325
Option.__init__(self, name, help, type=self.convert)
326
self.registry = registry
337
Option.__init__(self, name, help, type=self.convert,
338
short_name=short_name)
339
self._registry = registry
341
if lazy_registry is None:
342
raise AssertionError(
343
'One of registry or lazy_registry must be given.')
344
self._lazy_registry = _mod_registry._LazyObjectGetter(
346
if registry is not None and lazy_registry is not None:
347
raise AssertionError(
348
'registry and lazy_registry are mutually exclusive')
328
350
self.converter = converter
329
351
self.value_switches = value_switches
330
352
self.enum_switch = enum_switch
353
self.short_value_switches = short_value_switches
331
354
self.title = title
332
355
if self.title is None:
333
356
self.title = name
360
if self._registry is None:
361
self._registry = self._lazy_registry.get_obj()
362
return self._registry
336
365
def from_kwargs(name_, help=None, title=None, value_switches=False,
337
366
enum_switch=True, **kwargs):
428
477
Option.STD_OPTIONS[name] = Option(name, **kwargs)
429
478
Option.OPTIONS[name] = Option.STD_OPTIONS[name]
480
def _standard_list_option(name, **kwargs):
481
"""Register a standard option."""
482
# All standard options are implicitly 'global' ones
483
Option.STD_OPTIONS[name] = ListOption(name, **kwargs)
484
Option.OPTIONS[name] = Option.STD_OPTIONS[name]
432
487
def _global_option(name, **kwargs):
433
488
"""Register a global option."""
434
489
Option.OPTIONS[name] = Option(name, **kwargs)
437
def _global_registry_option(name, help, registry, **kwargs):
492
def _global_registry_option(name, help, registry=None, **kwargs):
438
493
Option.OPTIONS[name] = RegistryOption(name, help, registry, **kwargs)
441
class MergeTypeRegistry(registry.Registry):
446
496
# This is the verbosity level detected during command line parsing.
447
497
# Note that the final value is dependent on the order in which the
448
498
# various flags (verbose, quiet, no-verbose, no-quiet) are given.
471
521
_verbosity_level = -1
474
_merge_type_registry = MergeTypeRegistry()
475
_merge_type_registry.register_lazy('merge3', 'bzrlib.merge', 'Merge3Merger',
476
"Native diff3-style merge")
477
_merge_type_registry.register_lazy('diff3', 'bzrlib.merge', 'Diff3Merger',
478
"Merge using external diff3")
479
_merge_type_registry.register_lazy('weave', 'bzrlib.merge', 'WeaveMerger',
481
_merge_type_registry.register_lazy('lca', 'bzrlib.merge', 'LCAMerger',
484
524
# Declare the standard options
485
525
_standard_option('help', short_name='h',
486
526
help='Show help message.')
527
_standard_option('quiet', short_name='q',
528
help="Only display errors and warnings.",
529
custom_callback=_verbosity_level_callback)
530
_standard_option('usage',
531
help='Show usage message and options.')
487
532
_standard_option('verbose', short_name='v',
488
533
help='Display more information.',
489
534
custom_callback=_verbosity_level_callback)
490
_standard_option('quiet', short_name='q',
491
help="Only display errors and warnings.",
492
custom_callback=_verbosity_level_callback)
494
536
# Declare commonly used options
495
_global_option('all')
496
_global_option('overwrite', help='Ignore differences between branches and '
497
'overwrite unconditionally.')
498
_global_option('basis', type=str)
499
_global_option('bound')
500
_global_option('diff-options', type=str)
537
_global_option('change',
538
type=_parse_change_str,
540
param_name='revision',
541
help='Select changes introduced by the specified revision. See also "help revisionspec".')
542
_global_option('directory', short_name='d', type=unicode,
543
help='Branch to operate on, instead of working directory.')
501
544
_global_option('file', type=unicode, short_name='F')
502
_global_option('force')
503
_global_option('format', type=unicode)
504
_global_option('forward')
545
_global_registry_option('log-format', "Use specified log format.",
546
lazy_registry=('bzrlib.log', 'log_formatter_registry'),
547
value_switches=True, title='Log format',
548
short_value_switches={'short': 'S'})
549
_global_registry_option('merge-type', 'Select a particular merge algorithm.',
550
lazy_registry=('bzrlib.merge', 'merge_type_registry'),
551
value_switches=True, title='Merge algorithm')
505
552
_global_option('message', type=unicode,
507
554
help='Message string.')
508
_global_option('no-recurse')
509
_global_option('profile',
510
help='Show performance profiling information.')
555
_global_option('null', short_name='0',
556
help='Use an ASCII NUL (\\0) separator rather than '
558
_global_option('overwrite', help='Ignore differences between branches and '
559
'overwrite unconditionally.')
560
_global_option('remember', help='Remember the specified location as a'
562
_global_option('reprocess', help='Reprocess to reduce spurious conflicts.')
511
563
_global_option('revision',
512
564
type=_parse_revision_str,
514
566
help='See "help revisionspec" for details.')
515
_global_option('change',
516
type=_parse_change_str,
518
param_name='revision',
519
help='Select changes introduced by the specified revision. See also "help revisionspec".')
520
567
_global_option('show-ids',
521
568
help='Show internal object ids.')
522
_global_option('timezone',
569
_global_option('timezone',
524
help='display timezone as local, original, or utc')
525
_global_option('unbound')
526
_global_option('version')
527
_global_option('email')
528
_global_option('update')
529
_global_registry_option('log-format', "Use specified log format.",
530
log.log_formatter_registry, value_switches=True,
532
_global_option('long', help='Use detailed log format. Same as --log-format long',
534
_global_option('short', help='Use moderately short log format. Same as --log-format short')
535
_global_option('line', help='Use log format with one line per revision. Same as --log-format line')
536
_global_option('root', type=str)
537
_global_option('no-backup')
538
_global_registry_option('merge-type', 'Select a particular merge algorithm.',
539
_merge_type_registry, value_switches=True,
540
title='Merge algorithm')
541
_global_option('pattern', type=str)
542
_global_option('remember', help='Remember the specified location as a'
544
_global_option('reprocess', help='Reprocess to reduce spurious conflicts.')
545
_global_option('kind', type=str)
546
_global_option('dry-run',
547
help="Show what would be done, but don't actually do anything.")
548
_global_option('name-from-revision', help='The path name in the old tree.')
571
help='Display timezone as local, original, or utc.')
573
diff_writer_registry = _mod_registry.Registry()
574
diff_writer_registry.register('plain', lambda x: x, 'Plaintext diff output.')
575
diff_writer_registry.default_key = 'plain'