~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/option.py

  • Committer: Patch Queue Manager
  • Date: 2011-09-08 11:01:15 UTC
  • mfrom: (6123.1.16 gpg-typo)
  • Revision ID: pqm@cupuasso-20110908110115-gbb9benwkdksvzk5
(jelmer) Fix a typo (invalid format identifier) in an error message in
 bzrlib.gpg. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
332
332
        :param short_name: The short name for the enum switch, if any
333
333
        :param short_value_switches: A dict mapping values to short names
334
334
        """
335
 
        Option.__init__(self, name, help, type=self.convert,
336
 
                        short_name=short_name)
 
335
        Option.__init__(self, name, help, type=self.convert, short_name=short_name)
337
336
        self._registry = registry
338
337
        if registry is None:
339
338
            if lazy_registry is None:
438
437
    def error(self, message):
439
438
        raise errors.BzrCommandError(message)
440
439
 
441
 
 
442
440
class GettextIndentedHelpFormatter(optparse.IndentedHelpFormatter):
443
441
    """Adds gettext() call to format_option()"""
444
442
    def __init__(self):
450
448
            option.help = i18n.gettext(option.help)
451
449
        return optparse.IndentedHelpFormatter.format_option(self, option)
452
450
 
453
 
 
454
451
def get_optparser(options):
455
452
    """Generate an optparse parser for bzrlib-style options"""
456
453
 
475
472
    Option.STD_OPTIONS[name] = Option(name, **kwargs)
476
473
    Option.OPTIONS[name] = Option.STD_OPTIONS[name]
477
474
 
478
 
def _standard_list_option(name, **kwargs):
479
 
    """Register a standard option."""
480
 
    # All standard options are implicitly 'global' ones
481
 
    Option.STD_OPTIONS[name] = ListOption(name, **kwargs)
482
 
    Option.OPTIONS[name] = Option.STD_OPTIONS[name]
483
 
 
484
475
 
485
476
def _global_option(name, **kwargs):
486
477
    """Register a global option."""
525
516
 
526
517
 
527
518
_merge_type_registry = MergeTypeRegistry()
 
519
_merge_type_registry.register_lazy('merge3', 'bzrlib.merge', 'Merge3Merger',
 
520
                                   "Native diff3-style merge")
528
521
_merge_type_registry.register_lazy('diff3', 'bzrlib.merge', 'Diff3Merger',
529
522
                                   "Merge using external diff3")
 
523
_merge_type_registry.register_lazy('weave', 'bzrlib.merge', 'WeaveMerger',
 
524
                                   "Weave-based merge")
530
525
_merge_type_registry.register_lazy('lca', 'bzrlib.merge', 'LCAMerger',
531
526
                                   "LCA-newness merge")
532
 
_merge_type_registry.register_lazy('merge3', 'bzrlib.merge', 'Merge3Merger',
533
 
                                   "Native diff3-style merge")
534
 
_merge_type_registry.register_lazy('weave', 'bzrlib.merge', 'WeaveMerger',
535
 
                                   "Weave-based merge")
536
527
 
537
528
# Declare the standard options
538
529
_standard_option('help', short_name='h',
539
530
                 help='Show help message.')
540
 
_standard_option('quiet', short_name='q',
541
 
                 help="Only display errors and warnings.",
542
 
                 custom_callback=_verbosity_level_callback)
543
531
_standard_option('usage',
544
532
                 help='Show usage message and options.')
545
533
_standard_option('verbose', short_name='v',
546
534
                 help='Display more information.',
547
535
                 custom_callback=_verbosity_level_callback)
 
536
_standard_option('quiet', short_name='q',
 
537
                 help="Only display errors and warnings.",
 
538
                 custom_callback=_verbosity_level_callback)
548
539
 
549
540
# Declare commonly used options
550
541
_global_option('all')
 
542
_global_option('overwrite', help='Ignore differences between branches and '
 
543
               'overwrite unconditionally.')
551
544
_global_option('basis', type=str)
552
545
_global_option('bound')
553
 
_global_option('change',
554
 
               type=_parse_change_str,
555
 
               short_name='c',
556
 
               param_name='revision',
557
 
               help='Select changes introduced by the specified revision. See also "help revisionspec".')
558
546
_global_option('diff-options', type=str)
559
 
_global_option('directory', short_name='d', type=unicode,
560
 
               help='Branch to operate on, instead of working directory')
561
 
_global_option('dry-run',
562
 
               help="Show what would be done, but don't actually do anything.")
563
 
_global_option('email')
564
547
_global_option('file', type=unicode, short_name='F')
565
548
_global_option('force')
566
549
_global_option('format', type=unicode)
567
550
_global_option('forward')
568
 
_global_option('kind', type=str)
569
 
_global_option('line', help='Use log format with one line per revision.'
570
 
               ' Same as --log-format line')
571
 
_global_registry_option('log-format', "Use specified log format.",
572
 
                        lazy_registry=('bzrlib.log', 'log_formatter_registry'),
573
 
                        value_switches=True, title='Log format',
574
 
                        short_value_switches={'short': 'S'})
575
 
_global_option('long', help='Use detailed log format.'
576
 
               ' Same as --log-format long',
577
 
               short_name='l')
578
 
_global_registry_option('merge-type', 'Select a particular merge algorithm.',
579
 
                        _merge_type_registry, value_switches=True,
580
 
                        title='Merge algorithm')
581
551
_global_option('message', type=unicode,
582
552
               short_name='m',
583
553
               help='Message string.')
584
 
_global_option('name-from-revision', help='The path name in the old tree.')
585
 
_global_option('no-backup')
586
554
_global_option('no-recurse')
587
555
_global_option('null', short_name='0',
588
556
                 help='Use an ASCII NUL (\\0) separator rather than '
589
557
                      'a newline.')
590
 
_global_option('overwrite', help='Ignore differences between branches and '
591
 
               'overwrite unconditionally.')
592
 
_global_option('pattern', type=str)
593
558
_global_option('profile',
594
559
               help='Show performance profiling information.')
595
 
_global_option('reprocess', help='Reprocess to reduce spurious conflicts.')
596
 
_global_option('remember', help='Remember the specified location as a'
597
 
               ' default.')
598
560
_global_option('revision',
599
561
               type=_parse_revision_str,
600
562
               short_name='r',
601
563
               help='See "help revisionspec" for details.')
602
 
_global_option('short', help='Use moderately short log format.'
603
 
               ' Same as --log-format short')
 
564
_global_option('change',
 
565
               type=_parse_change_str,
 
566
               short_name='c',
 
567
               param_name='revision',
 
568
               help='Select changes introduced by the specified revision. See also "help revisionspec".')
604
569
_global_option('show-ids',
605
570
               help='Show internal object ids.')
606
571
_global_option('timezone',
607
572
               type=str,
608
573
               help='Display timezone as local, original, or utc.')
609
 
_global_option('root', type=str)
610
574
_global_option('unbound')
 
575
_global_option('version')
 
576
_global_option('email')
611
577
_global_option('update')
612
 
_global_option('version')
 
578
_global_registry_option('log-format', "Use specified log format.",
 
579
                        lazy_registry=('bzrlib.log', 'log_formatter_registry'),
 
580
                        value_switches=True, title='Log format',
 
581
                        short_value_switches={'short': 'S'})
 
582
_global_option('long', help='Use detailed log format. Same as --log-format long',
 
583
               short_name='l')
 
584
_global_option('short', help='Use moderately short log format. Same as --log-format short')
 
585
_global_option('line', help='Use log format with one line per revision. Same as --log-format line')
 
586
_global_option('root', type=str)
 
587
_global_option('no-backup')
 
588
_global_registry_option('merge-type', 'Select a particular merge algorithm.',
 
589
                        _merge_type_registry, value_switches=True,
 
590
                        title='Merge algorithm')
 
591
_global_option('pattern', type=str)
 
592
_global_option('remember', help='Remember the specified location as a'
 
593
               ' default.')
 
594
_global_option('reprocess', help='Reprocess to reduce spurious conflicts.')
 
595
_global_option('kind', type=str)
 
596
_global_option('dry-run',
 
597
               help="Show what would be done, but don't actually do anything.")
 
598
_global_option('name-from-revision', help='The path name in the old tree.')
 
599
_global_option('directory', short_name='d', type=unicode,
 
600
               help='Branch to operate on, instead of working directory')
613
601
 
614
602
diff_writer_registry = _mod_registry.Registry()
615
603
diff_writer_registry.register('plain', lambda x: x, 'Plaintext diff output.')