~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-22 16:23:20 UTC
  • mfrom: (6154.1.3 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20110922162320-dk4lq4mn9jk10qhf
(vila) Sort cmdline options declarations (in option.py) by name to
 make it easier to add a new one. (Vincent Ladeuil)

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, short_name=short_name)
 
335
        Option.__init__(self, name, help, type=self.convert,
 
336
                        short_name=short_name)
336
337
        self._registry = registry
337
338
        if registry is None:
338
339
            if lazy_registry is None:
437
438
    def error(self, message):
438
439
        raise errors.BzrCommandError(message)
439
440
 
 
441
 
440
442
class GettextIndentedHelpFormatter(optparse.IndentedHelpFormatter):
441
443
    """Adds gettext() call to format_option()"""
442
444
    def __init__(self):
448
450
            option.help = i18n.gettext(option.help)
449
451
        return optparse.IndentedHelpFormatter.format_option(self, option)
450
452
 
 
453
 
451
454
def get_optparser(options):
452
455
    """Generate an optparse parser for bzrlib-style options"""
453
456
 
516
519
 
517
520
 
518
521
_merge_type_registry = MergeTypeRegistry()
 
522
_merge_type_registry.register_lazy('diff3', 'bzrlib.merge', 'Diff3Merger',
 
523
                                   "Merge using external diff3")
 
524
_merge_type_registry.register_lazy('lca', 'bzrlib.merge', 'LCAMerger',
 
525
                                   "LCA-newness merge")
519
526
_merge_type_registry.register_lazy('merge3', 'bzrlib.merge', 'Merge3Merger',
520
527
                                   "Native diff3-style merge")
521
 
_merge_type_registry.register_lazy('diff3', 'bzrlib.merge', 'Diff3Merger',
522
 
                                   "Merge using external diff3")
523
528
_merge_type_registry.register_lazy('weave', 'bzrlib.merge', 'WeaveMerger',
524
529
                                   "Weave-based merge")
525
 
_merge_type_registry.register_lazy('lca', 'bzrlib.merge', 'LCAMerger',
526
 
                                   "LCA-newness merge")
527
530
 
528
531
# Declare the standard options
529
532
_standard_option('help', short_name='h',
539
542
 
540
543
# Declare commonly used options
541
544
_global_option('all')
542
 
_global_option('overwrite', help='Ignore differences between branches and '
543
 
               'overwrite unconditionally.')
544
545
_global_option('basis', type=str)
545
546
_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".')
546
552
_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')
547
558
_global_option('file', type=unicode, short_name='F')
548
559
_global_option('force')
549
560
_global_option('format', type=unicode)
550
561
_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')
551
575
_global_option('message', type=unicode,
552
576
               short_name='m',
553
577
               help='Message string.')
 
578
_global_option('name-from-revision', help='The path name in the old tree.')
 
579
_global_option('no-backup')
554
580
_global_option('no-recurse')
555
581
_global_option('null', short_name='0',
556
582
                 help='Use an ASCII NUL (\\0) separator rather than '
557
583
                      'a newline.')
 
584
_global_option('overwrite', help='Ignore differences between branches and '
 
585
               'overwrite unconditionally.')
 
586
_global_option('pattern', type=str)
558
587
_global_option('profile',
559
588
               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.')
560
592
_global_option('revision',
561
593
               type=_parse_revision_str,
562
594
               short_name='r',
563
595
               help='See "help revisionspec" for details.')
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".')
 
596
_global_option('short', help='Use moderately short log format.'
 
597
               ' Same as --log-format short')
569
598
_global_option('show-ids',
570
599
               help='Show internal object ids.')
571
600
_global_option('timezone',
572
601
               type=str,
573
602
               help='Display timezone as local, original, or utc.')
 
603
_global_option('root', type=str)
574
604
_global_option('unbound')
 
605
_global_option('update')
575
606
_global_option('version')
576
 
_global_option('email')
577
 
_global_option('update')
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')
601
607
 
602
608
diff_writer_registry = _mod_registry.Registry()
603
609
diff_writer_registry.register('plain', lambda x: x, 'Plaintext diff output.')