~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/option.py

  • Committer: Jonathan Riddell
  • Date: 2011-09-20 13:31:00 UTC
  • mto: This revision was merged to the branch mainline in revision 6153.
  • Revision ID: jriddell@canonical.com-20110920133100-kpsomvcnjoxv6n6b
syntax fixes

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
 
519
516
 
520
517
 
521
518
_merge_type_registry = MergeTypeRegistry()
 
519
_merge_type_registry.register_lazy('merge3', 'bzrlib.merge', 'Merge3Merger',
 
520
                                   "Native diff3-style merge")
522
521
_merge_type_registry.register_lazy('diff3', 'bzrlib.merge', 'Diff3Merger',
523
522
                                   "Merge using external diff3")
 
523
_merge_type_registry.register_lazy('weave', 'bzrlib.merge', 'WeaveMerger',
 
524
                                   "Weave-based merge")
524
525
_merge_type_registry.register_lazy('lca', 'bzrlib.merge', 'LCAMerger',
525
526
                                   "LCA-newness merge")
526
 
_merge_type_registry.register_lazy('merge3', 'bzrlib.merge', 'Merge3Merger',
527
 
                                   "Native diff3-style merge")
528
 
_merge_type_registry.register_lazy('weave', 'bzrlib.merge', 'WeaveMerger',
529
 
                                   "Weave-based merge")
530
527
 
531
528
# Declare the standard options
532
529
_standard_option('help', short_name='h',
542
539
 
543
540
# Declare commonly used options
544
541
_global_option('all')
 
542
_global_option('overwrite', help='Ignore differences between branches and '
 
543
               'overwrite unconditionally.')
545
544
_global_option('basis', type=str)
546
545
_global_option('bound')
547
 
_global_option('change',
548
 
               type=_parse_change_str,
549
 
               short_name='c',
550
 
               param_name='revision',
551
 
               help='Select changes introduced by the specified revision. See also "help revisionspec".')
552
546
_global_option('diff-options', type=str)
553
 
_global_option('directory', short_name='d', type=unicode,
554
 
               help='Branch to operate on, instead of working directory')
555
 
_global_option('dry-run',
556
 
               help="Show what would be done, but don't actually do anything.")
557
 
_global_option('email')
558
547
_global_option('file', type=unicode, short_name='F')
559
548
_global_option('force')
560
549
_global_option('format', type=unicode)
561
550
_global_option('forward')
562
 
_global_option('kind', type=str)
563
 
_global_option('line', help='Use log format with one line per revision.'
564
 
               ' Same as --log-format line')
565
 
_global_registry_option('log-format', "Use specified log format.",
566
 
                        lazy_registry=('bzrlib.log', 'log_formatter_registry'),
567
 
                        value_switches=True, title='Log format',
568
 
                        short_value_switches={'short': 'S'})
569
 
_global_option('long', help='Use detailed log format.'
570
 
               ' Same as --log-format long',
571
 
               short_name='l')
572
 
_global_registry_option('merge-type', 'Select a particular merge algorithm.',
573
 
                        _merge_type_registry, value_switches=True,
574
 
                        title='Merge algorithm')
575
551
_global_option('message', type=unicode,
576
552
               short_name='m',
577
553
               help='Message string.')
578
 
_global_option('name-from-revision', help='The path name in the old tree.')
579
 
_global_option('no-backup')
580
554
_global_option('no-recurse')
581
555
_global_option('null', short_name='0',
582
556
                 help='Use an ASCII NUL (\\0) separator rather than '
583
557
                      'a newline.')
584
 
_global_option('overwrite', help='Ignore differences between branches and '
585
 
               'overwrite unconditionally.')
586
 
_global_option('pattern', type=str)
587
558
_global_option('profile',
588
559
               help='Show performance profiling information.')
589
 
_global_option('reprocess', help='Reprocess to reduce spurious conflicts.')
590
 
_global_option('remember', help='Remember the specified location as a'
591
 
               ' default.')
592
560
_global_option('revision',
593
561
               type=_parse_revision_str,
594
562
               short_name='r',
595
563
               help='See "help revisionspec" for details.')
596
 
_global_option('short', help='Use moderately short log format.'
597
 
               ' 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".')
598
569
_global_option('show-ids',
599
570
               help='Show internal object ids.')
600
571
_global_option('timezone',
601
572
               type=str,
602
573
               help='Display timezone as local, original, or utc.')
603
 
_global_option('root', type=str)
604
574
_global_option('unbound')
 
575
_global_option('version')
 
576
_global_option('email')
605
577
_global_option('update')
606
 
_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')
607
601
 
608
602
diff_writer_registry = _mod_registry.Registry()
609
603
diff_writer_registry.register('plain', lambda x: x, 'Plaintext diff output.')