42
40
each revision specifier supplied.
44
42
>>> _parse_revision_str('234')
45
[<RevisionSpec_dwim 234>]
43
[<RevisionSpec_revno 234>]
46
44
>>> _parse_revision_str('234..567')
47
[<RevisionSpec_dwim 234>, <RevisionSpec_dwim 567>]
45
[<RevisionSpec_revno 234>, <RevisionSpec_revno 567>]
48
46
>>> _parse_revision_str('..')
49
47
[<RevisionSpec None>, <RevisionSpec None>]
50
48
>>> _parse_revision_str('..234')
51
[<RevisionSpec None>, <RevisionSpec_dwim 234>]
49
[<RevisionSpec None>, <RevisionSpec_revno 234>]
52
50
>>> _parse_revision_str('234..')
53
[<RevisionSpec_dwim 234>, <RevisionSpec None>]
51
[<RevisionSpec_revno 234>, <RevisionSpec None>]
54
52
>>> _parse_revision_str('234..456..789') # Maybe this should be an error
55
[<RevisionSpec_dwim 234>, <RevisionSpec_dwim 456>, <RevisionSpec_dwim 789>]
53
[<RevisionSpec_revno 234>, <RevisionSpec_revno 456>, <RevisionSpec_revno 789>]
56
54
>>> _parse_revision_str('234....789') #Error ?
57
[<RevisionSpec_dwim 234>, <RevisionSpec None>, <RevisionSpec_dwim 789>]
55
[<RevisionSpec_revno 234>, <RevisionSpec None>, <RevisionSpec_revno 789>]
58
56
>>> _parse_revision_str('revid:test@other.com-234234')
59
57
[<RevisionSpec_revid revid:test@other.com-234234>]
60
58
>>> _parse_revision_str('revid:test@other.com-234234..revid:test@other.com-234235')
61
59
[<RevisionSpec_revid revid:test@other.com-234234>, <RevisionSpec_revid revid:test@other.com-234235>]
62
60
>>> _parse_revision_str('revid:test@other.com-234234..23')
63
[<RevisionSpec_revid revid:test@other.com-234234>, <RevisionSpec_dwim 23>]
61
[<RevisionSpec_revid revid:test@other.com-234234>, <RevisionSpec_revno 23>]
64
62
>>> _parse_revision_str('date:2005-04-12')
65
63
[<RevisionSpec_date date:2005-04-12>]
66
64
>>> _parse_revision_str('date:2005-04-12 12:24:33')
70
68
>>> _parse_revision_str('date:2005-04-12,12:24:33')
71
69
[<RevisionSpec_date date:2005-04-12,12:24:33>]
72
70
>>> _parse_revision_str('-5..23')
73
[<RevisionSpec_dwim -5>, <RevisionSpec_dwim 23>]
71
[<RevisionSpec_revno -5>, <RevisionSpec_revno 23>]
74
72
>>> _parse_revision_str('-5')
75
[<RevisionSpec_dwim -5>]
73
[<RevisionSpec_revno -5>]
76
74
>>> _parse_revision_str('123a')
77
[<RevisionSpec_dwim 123a>]
75
Traceback (most recent call last):
77
NoSuchRevisionSpec: No namespace registered for string: '123a'
78
78
>>> _parse_revision_str('abc')
79
[<RevisionSpec_dwim abc>]
79
Traceback (most recent call last):
81
NoSuchRevisionSpec: No namespace registered for string: 'abc'
80
82
>>> _parse_revision_str('branch:../branch2')
81
83
[<RevisionSpec_branch branch:../branch2>]
82
84
>>> _parse_revision_str('branch:../../branch2')
83
85
[<RevisionSpec_branch branch:../../branch2>]
84
86
>>> _parse_revision_str('branch:../../branch2..23')
85
[<RevisionSpec_branch branch:../../branch2>, <RevisionSpec_dwim 23>]
87
[<RevisionSpec_branch branch:../../branch2>, <RevisionSpec_revno 23>]
86
88
>>> _parse_revision_str('branch:..\\\\branch2')
87
89
[<RevisionSpec_branch branch:..\\branch2>]
88
90
>>> _parse_revision_str('branch:..\\\\..\\\\branch2..23')
89
[<RevisionSpec_branch branch:..\\..\\branch2>, <RevisionSpec_dwim 23>]
91
[<RevisionSpec_branch branch:..\\..\\branch2>, <RevisionSpec_revno 23>]
91
93
# TODO: Maybe move this into revisionspec.py
451
427
DEFAULT_VALUE = object()
454
optparse.OptionParser.__init__(self)
455
self.formatter = GettextIndentedHelpFormatter()
457
429
def error(self, message):
458
raise errors.CommandError(message)
461
class GettextIndentedHelpFormatter(optparse.IndentedHelpFormatter):
462
"""Adds gettext() call to format_option()"""
465
optparse.IndentedHelpFormatter.__init__(self)
467
def format_option(self, option):
468
"""code taken from Python's optparse.py"""
470
from .i18n import gettext
471
option.help = gettext(option.help)
472
return optparse.IndentedHelpFormatter.format_option(self, option)
430
raise errors.BzrCommandError(message)
475
433
def get_optparser(options):
476
"""Generate an optparse parser for breezy-style options"""
434
"""Generate an optparse parser for bzrlib-style options"""
478
436
parser = OptionParser()
479
437
parser.remove_option('--help')
480
for option in options:
438
for option in options.itervalues():
481
439
option.add_option(parser, option.short_name())
541
492
_verbosity_level = -1
495
class MergeTypeRegistry(_mod_registry.Registry):
500
_merge_type_registry = MergeTypeRegistry()
501
_merge_type_registry.register_lazy('merge3', 'bzrlib.merge', 'Merge3Merger',
502
"Native diff3-style merge")
503
_merge_type_registry.register_lazy('diff3', 'bzrlib.merge', 'Diff3Merger',
504
"Merge using external diff3")
505
_merge_type_registry.register_lazy('weave', 'bzrlib.merge', 'WeaveMerger',
507
_merge_type_registry.register_lazy('lca', 'bzrlib.merge', 'LCAMerger',
544
510
# Declare the standard options
545
511
_standard_option('help', short_name='h',
546
512
help='Show help message.')
547
_standard_option('quiet', short_name='q',
548
help="Only display errors and warnings.",
549
custom_callback=_verbosity_level_callback)
550
513
_standard_option('usage',
551
514
help='Show usage message and options.')
552
515
_standard_option('verbose', short_name='v',
553
516
help='Display more information.',
554
517
custom_callback=_verbosity_level_callback)
518
_standard_option('quiet', short_name='q',
519
help="Only display errors and warnings.",
520
custom_callback=_verbosity_level_callback)
556
522
# Declare commonly used options
557
_global_option('change',
558
type=_parse_change_str,
560
param_name='revision',
561
help='Select changes introduced by the specified revision. See also "help revisionspec".')
562
_global_option('directory', short_name='d', type=str,
563
help='Branch to operate on, instead of working directory.')
564
_global_option('file', type=str, short_name='F')
565
_global_registry_option('log-format', "Use specified log format.",
566
lazy_registry=('breezy.log', 'log_formatter_registry'),
567
value_switches=True, title='Log format',
568
short_value_switches={'short': 'S'})
569
_global_registry_option('merge-type', 'Select a particular merge algorithm.',
570
lazy_registry=('breezy.merge', 'merge_type_registry'),
571
value_switches=True, title='Merge algorithm')
572
_global_option('message', type=str,
523
_global_option('all')
524
_global_option('overwrite', help='Ignore differences between branches and '
525
'overwrite unconditionally.')
526
_global_option('basis', type=str)
527
_global_option('bound')
528
_global_option('diff-options', type=str)
529
_global_option('file', type=unicode, short_name='F')
530
_global_option('force')
531
_global_option('format', type=unicode)
532
_global_option('forward')
533
_global_option('message', type=unicode,
574
535
help='Message string.')
575
_global_option('null', short_name='0',
576
help='Use an ASCII NUL (\\0) separator rather than '
578
_global_option('overwrite', help='Ignore differences between branches and '
579
'overwrite unconditionally.')
580
_global_option('remember', help='Remember the specified location as a'
582
_global_option('reprocess', help='Reprocess to reduce spurious conflicts.')
536
_global_option('no-recurse')
537
_global_option('profile',
538
help='Show performance profiling information.')
583
539
_global_option('revision',
584
540
type=_parse_revision_str,
586
542
help='See "help revisionspec" for details.')
543
_global_option('change',
544
type=_parse_change_str,
546
param_name='revision',
547
help='Select changes introduced by the specified revision. See also "help revisionspec".')
587
548
_global_option('show-ids',
588
549
help='Show internal object ids.')
589
550
_global_option('timezone',
591
552
help='Display timezone as local, original, or utc.')
553
_global_option('unbound')
554
_global_option('version')
555
_global_option('email')
556
_global_option('update')
557
_global_registry_option('log-format', "Use specified log format.",
558
lazy_registry=('bzrlib.log', 'log_formatter_registry'),
559
value_switches=True, title='Log format')
560
_global_option('long', help='Use detailed log format. Same as --log-format long',
562
_global_option('short', help='Use moderately short log format. Same as --log-format short')
563
_global_option('line', help='Use log format with one line per revision. Same as --log-format line')
564
_global_option('root', type=str)
565
_global_option('no-backup')
566
_global_registry_option('merge-type', 'Select a particular merge algorithm.',
567
_merge_type_registry, value_switches=True,
568
title='Merge algorithm')
569
_global_option('pattern', type=str)
570
_global_option('remember', help='Remember the specified location as a'
572
_global_option('reprocess', help='Reprocess to reduce spurious conflicts.')
573
_global_option('kind', type=str)
574
_global_option('dry-run',
575
help="Show what would be done, but don't actually do anything.")
576
_global_option('name-from-revision', help='The path name in the old tree.')
593
578
diff_writer_registry = _mod_registry.Registry()
594
579
diff_writer_registry.register('plain', lambda x: x, 'Plaintext diff output.')