/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/help_topics/__init__.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-11-16 18:59:44 UTC
  • mfrom: (7143.15.15 more-cleanups)
  • Revision ID: breezy.the.bot@gmail.com-20181116185944-biefv1sub37qfybm
Sprinkle some PEP8iness.

Merged from https://code.launchpad.net/~jelmer/brz/more-cleanups/+merge/358611

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
# Section identifiers (map topics to the right place in the manual)
48
48
SECT_COMMAND = "command"
49
49
SECT_CONCEPT = "concept"
50
 
SECT_HIDDEN =  "hidden"
51
 
SECT_LIST    = "list"
52
 
SECT_PLUGIN  = "plugin"
 
50
SECT_HIDDEN = "hidden"
 
51
SECT_LIST = "list"
 
52
SECT_PLUGIN = "plugin"
53
53
 
54
54
 
55
55
class HelpTopicRegistry(registry.Registry):
121
121
topic_registry = HelpTopicRegistry()
122
122
 
123
123
 
124
 
#----------------------------------------------------
 
124
# ----------------------------------------------------
125
125
 
126
126
def _help_on_topics(dummy):
127
127
    """Write out the help for topics to outfile"""
152
152
 
153
153
    out = []
154
154
    out.append(
155
 
"""Revision Identifiers
 
155
        """Revision Identifiers
156
156
 
157
157
A revision identifier refers to a specific state of a branch's history.  It
158
158
can be expressed in several ways.  It can begin with a keyword to
183
183
""")
184
184
    details = []
185
185
    details.append("\nIn addition, plugins can provide other keywords.")
186
 
    details.append("\nA detailed description of each keyword is given below.\n")
 
186
    details.append(
 
187
        "\nA detailed description of each keyword is given below.\n")
187
188
 
188
189
    # The help text is indented 4 spaces - this re cleans that up below
189
190
    indent_re = re.compile(r'^    ', re.MULTILINE)
215
216
    import textwrap
216
217
 
217
218
    def add_string(proto, help, maxl, prefix_width=20):
218
 
       help_lines = textwrap.wrap(help, maxl - prefix_width,
219
 
            break_long_words=False)
220
 
       line_with_indent = '\n' + ' ' * prefix_width
221
 
       help_text = line_with_indent.join(help_lines)
222
 
       return "%-20s%s\n" % (proto, help_text)
 
219
        help_lines = textwrap.wrap(help, maxl - prefix_width,
 
220
                                   break_long_words=False)
 
221
        line_with_indent = '\n' + ' ' * prefix_width
 
222
        help_text = line_with_indent.join(help_lines)
 
223
        return "%-20s%s\n" % (proto, help_text)
223
224
 
224
225
    def key_func(a):
225
226
        return a[:a.rfind("://")]
237
238
        else:
238
239
            decl.append(add_string(proto, shorthelp, 79))
239
240
 
240
 
 
241
241
    out = "URL Identifiers\n\n" + \
242
 
            "Supported URL prefixes::\n\n  " + \
243
 
            '  '.join(protl)
 
242
        "Supported URL prefixes::\n\n  " + \
 
243
        '  '.join(protl)
244
244
 
245
245
    if len(decl):
246
246
        out += "\nSupported modifiers::\n\n  " + \
273
273
 
274
274
 
275
275
_basic_help = \
276
 
"""Breezy %s -- a free distributed version-control tool
 
276
    """Breezy %s -- a free distributed version-control tool
277
277
https://www.breezy-vcs.org/
278
278
 
279
279
Basic commands:
301
301
 
302
302
 
303
303
_global_options = \
304
 
"""Global Options
 
304
    """Global Options
305
305
 
306
306
These options may be used with any command, and may appear in front of any
307
307
command.  (e.g. ``brz --profile help``).
336
336
"""
337
337
 
338
338
_standard_options = \
339
 
"""Standard Options
 
339
    """Standard Options
340
340
 
341
341
Standard options are legal for all commands.
342
342
 
349
349
 
350
350
 
351
351
_checkouts = \
352
 
"""Checkouts
 
352
    """Checkouts
353
353
 
354
354
Checkouts are source trees that are connected to a branch, so that when
355
355
you commit in the source tree, the commit goes into that branch.  They
433
433
"""
434
434
 
435
435
_repositories = \
436
 
"""Repositories
 
436
    """Repositories
437
437
 
438
438
Repositories in Breezy are where committed information is stored. There is
439
439
a repository associated with every branch.
476
476
 
477
477
 
478
478
_working_trees = \
479
 
"""Working Trees
 
479
    """Working Trees
480
480
 
481
481
A working tree is the contents of a branch placed on disk so that you can
482
482
see the files and edit them. The working tree is where you make changes to a
518
518
 
519
519
 
520
520
_branches = \
521
 
"""Branches
 
521
    """Branches
522
522
 
523
523
A branch consists of the state of a project, including all of its
524
524
history. All branches have a repository associated (which is where the
542
542
 
543
543
 
544
544
_standalone_trees = \
545
 
"""Standalone Trees
 
545
    """Standalone Trees
546
546
 
547
547
A standalone tree is a working tree with an associated repository. It
548
548
is an independently usable branch, with no dependencies on any other.
556
556
 
557
557
 
558
558
_status_flags = \
559
 
"""Status Flags
 
559
    """Status Flags
560
560
 
561
561
Status flags are used to summarise changes to the working tree in a concise
562
562
manner.  They are in the form::
607
607
    ("BRZ_CONCURRENCY", "Number of processes that can be run concurrently (selftest)"),
608
608
    ("BRZ_PROGRESS_BAR", "Override the progress display. Values are 'none' or 'text'."),
609
609
    ("BRZ_PDB", "Control whether to launch a debugger on error."),
610
 
    ("BRZ_SIGQUIT_PDB", "Control whether SIGQUIT behaves normally or invokes a breakin debugger."),
611
 
    ("BRZ_TEXTUI_INPUT", "Force console input mode for prompts to line-based (instead of char-based)."),
 
610
    ("BRZ_SIGQUIT_PDB",
 
611
     "Control whether SIGQUIT behaves normally or invokes a breakin debugger."),
 
612
    ("BRZ_TEXTUI_INPUT",
 
613
     "Force console input mode for prompts to line-based (instead of char-based)."),
612
614
    ]
613
615
 
 
616
 
614
617
def _env_variables(topic):
615
618
    import textwrap
616
619
    ret = ["Environment Variables\n\n"
617
 
        "See brz help configuration for more details.\n\n"]
 
620
           "See brz help configuration for more details.\n\n"]
618
621
    max_key_len = max([len(k[0]) for k in known_env_variables])
619
622
    desc_len = (80 - max_key_len - 2)
620
623
    ret.append("=" * max_key_len + " " + "=" * desc_len + "\n")
626
629
    ret += "=" * max_key_len + " " + "=" * desc_len + "\n"
627
630
    return "".join(ret)
628
631
 
 
632
 
629
633
_files = \
630
 
r"""Files
 
634
    r"""Files
631
635
 
632
636
:On Unix:   ~/.config/breezy/breezy.conf
633
637
:On Windows: C:\\Documents and Settings\\username\\Application Data\\Breezy\\2.0\\breezy.conf
648
652
"""
649
653
 
650
654
_criss_cross = \
651
 
"""Criss-Cross
 
655
    """Criss-Cross
652
656
 
653
657
A criss-cross in the branch history can cause the default merge technique
654
658
to emit more conflicts than would normally be expected.
700
704
 
701
705
 
702
706
_storage_formats = \
703
 
"""Storage Formats
 
707
    """Storage Formats
704
708
 
705
709
To ensure that older clients do not access data incorrectly,
706
710
Breezy's policy is to introduce a new storage format whenever
736
740
                        "Explain how to use --revision")
737
741
topic_registry.register('basic', _basic_help, "Basic commands", SECT_HIDDEN)
738
742
topic_registry.register('topics', _help_on_topics, "Topics list", SECT_HIDDEN)
 
743
 
 
744
 
739
745
def get_current_formats_topic(topic):
740
746
    from breezy import controldir
741
747
    return "Current Storage Formats\n\n" + \
742
748
        controldir.format_registry.help_topic(topic)
 
749
 
 
750
 
743
751
def get_other_formats_topic(topic):
744
752
    from breezy import controldir
745
753
    return "Other Storage Formats\n\n" + \
746
754
        controldir.format_registry.help_topic(topic)
 
755
 
 
756
 
747
757
topic_registry.register('current-formats', get_current_formats_topic,
748
 
    'Current storage formats')
 
758
                        'Current storage formats')
749
759
topic_registry.register('other-formats', get_other_formats_topic,
750
 
    'Experimental and deprecated storage formats')
 
760
                        'Experimental and deprecated storage formats')
751
761
topic_registry.register('standard-options', _standard_options,
752
762
                        'Options that can be used with any command')
753
763
topic_registry.register('global-options', _global_options,
754
 
                    'Options that control how Breezy runs')
 
764
                        'Options that control how Breezy runs')
755
765
topic_registry.register('urlspec', _help_on_transport,
756
766
                        "Supported transport protocols")
757
767
topic_registry.register('status-flags', _status_flags,
758
768
                        "Help on status flags")
 
769
 
 
770
 
759
771
def get_bugs_topic(topic):
760
772
    from breezy import bugtracker
761
 
    return ("Bug Tracker Settings\n\n" +
762
 
        bugtracker.tracker_registry.help_topic(topic))
 
773
    return ("Bug Tracker Settings\n\n"
 
774
            + bugtracker.tracker_registry.help_topic(topic))
 
775
 
 
776
 
763
777
topic_registry.register('bugs', get_bugs_topic, 'Bug tracker settings')
764
778
topic_registry.register('env-variables', _env_variables,
765
779
                        'Environment variable names and values')
766
780
topic_registry.register('files', _files,
767
781
                        'Information on configuration and log files')
768
782
topic_registry.register_lazy('hooks', 'breezy.hooks', 'hooks_help_text',
769
 
                        'Points at which custom processing can be added')
 
783
                             'Points at which custom processing can be added')
770
784
topic_registry.register_lazy('location-alias', 'breezy.directory_service',
771
 
                        'AliasDirectory.help_text',
772
 
                        'Aliases for remembered locations')
 
785
                             'AliasDirectory.help_text',
 
786
                             'Aliases for remembered locations')
773
787
 
774
788
# Load some of the help topics from files. Note that topics which reproduce API
775
789
# details will tend to skew (quickly usually!) so please seek other solutions
935
949
            return [config.option_registry.get(topic)]
936
950
        else:
937
951
            return []
938
 
 
939