/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 bzrlib/help_topics/__init__.py

Merge bzr.dev, update to use new hooks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006-2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
33
33
rendering on the screen naturally.
34
34
"""
35
35
 
36
 
import sys
37
 
 
38
36
import bzrlib
39
37
from bzrlib import (
 
38
    config,
40
39
    osutils,
41
40
    registry,
 
41
    i18n,
42
42
    )
43
43
 
44
44
 
65
65
        :param section: Section in reference manual - see SECT_* identifiers.
66
66
        """
67
67
        # The detail is stored as the 'object' and the metadata as the info
68
 
        info=(summary,section)
 
68
        info = (summary, section)
69
69
        super(HelpTopicRegistry, self).register(topic, detail, info=info)
70
70
 
71
71
    def register_lazy(self, topic, module_name, member_name, summary,
79
79
        :param section: Section in reference manual - see SECT_* identifiers.
80
80
        """
81
81
        # The detail is stored as the 'object' and the metadata as the info
82
 
        info=(summary,section)
 
82
        info = (summary, section)
83
83
        super(HelpTopicRegistry, self).register_lazy(topic, module_name,
84
84
                                                     member_name, info=info)
85
85
 
270
270
 
271
271
would refer to ``/home/remote/myproject/trunk``.
272
272
 
273
 
Many commands that accept URLs also accept location aliases too.  See
274
 
::doc:`location-alias-help`.
 
273
Many commands that accept URLs also accept location aliases too.
 
274
See :doc:`location-alias-help` and :doc:`url-special-chars-help`.
275
275
"""
276
276
 
277
277
    return out
316
316
--builtin      Use the built-in version of a command, not the plugin version.
317
317
               This does not suppress other plugin effects.
318
318
--no-plugins   Do not process any plugins.
 
319
--no-l10n      Do not translate messages.
319
320
--concurrency  Number of processes that can be run concurrently (selftest).
320
321
 
321
322
--profile      Profile execution using the hotshot profiler.
328
329
               will be a pickle.
329
330
--coverage     Generate line coverage report in the specified directory.
330
331
 
 
332
-Oname=value   Override the ``name`` config option setting it to ``value`` for
 
333
               the duration of the command.  This can be used multiple times if
 
334
               several options need to be overridden.
 
335
 
331
336
See http://doc.bazaar.canonical.com/developers/profiling.html for more
332
337
information on profiling.
333
338
 
512
517
 
513
518
  checkout     Create a working tree when a branch does not have one.
514
519
  remove-tree  Removes the working tree from a branch when it is safe to do so.
515
 
  update       When a working tree is out of sync with it's associated branch
 
520
  update       When a working tree is out of sync with its associated branch
516
521
               this will update the tree to match the branch.
517
522
"""
518
523
 
591
596
_env_variables = \
592
597
"""Environment Variables
593
598
 
594
 
=================== =======================================================================
595
 
BZRPATH             Path where bzr is to look for shell plugin external commands.
 
599
=================== ===========================================================
 
600
BZRPATH             Path where bzr is to look for shell plugin external
 
601
                    commands.
596
602
BZR_EMAIL           E-Mail address of the user. Overrides EMAIL.
597
603
EMAIL               E-Mail address of the user.
598
604
BZR_EDITOR          Editor for editing commit messages. Overrides EDITOR.
601
607
BZR_DISABLE_PLUGINS Plugins that bzr should not load.
602
608
BZR_PLUGINS_AT      Plugins to load from a directory not in BZR_PLUGIN_PATH.
603
609
BZR_HOME            Directory holding .bazaar config dir. Overrides HOME.
604
 
BZR_HOME (Win32)    Directory holding bazaar config dir. Overrides APPDATA and HOME.
 
610
BZR_HOME (Win32)    Directory holding bazaar config dir. Overrides APPDATA and
 
611
                    HOME.
605
612
BZR_REMOTE_PATH     Full name of remote 'bzr' command (for bzr+ssh:// URLs).
606
 
BZR_SSH             Path to SSH client, or one of paramiko, openssh, sshcorp, plink.
 
613
BZR_SSH             Path to SSH client, or one of paramiko, openssh, sshcorp,
 
614
                    plink or lsh.
607
615
BZR_LOG             Location of .bzr.log (use '/dev/null' to suppress log).
608
616
BZR_LOG (Win32)     Location of .bzr.log (use 'NUL' to suppress log).
609
617
BZR_COLUMNS         Override implicit terminal width.
610
 
BZR_CONCURRENCY     Number of processes that can be run concurrently (selftest).
611
 
BZR_PROGRESS_BAR    Override the progress display. Values are 'none', 'dots', or 'tty'.
 
618
BZR_CONCURRENCY     Number of processes that can be run concurrently (selftest)
 
619
BZR_PROGRESS_BAR    Override the progress display. Values are 'none' or 'text'.
612
620
BZR_PDB             Control whether to launch a debugger on error.
613
 
BZR_SIGQUIT_PDB     Control whether SIGQUIT behaves normally or invokes a breakin debugger.
614
 
=================== =======================================================================
 
621
BZR_SIGQUIT_PDB     Control whether SIGQUIT behaves normally or invokes a
 
622
                    breakin debugger.
 
623
BZR_TEXTUI_INPUT    Force console input mode for prompts to line-based (instead
 
624
                    of char-based).
 
625
=================== ===========================================================
615
626
"""
616
627
 
617
628
 
756
767
                        'Information on configuration and log files')
757
768
topic_registry.register_lazy('hooks', 'bzrlib.hooks', 'hooks_help_text',
758
769
                        'Points at which custom processing can be added')
 
770
topic_registry.register_lazy('location-alias', 'bzrlib.directory_service',
 
771
                        'AliasDirectory.help_text',
 
772
                        'Aliases for remembered locations')
759
773
 
760
774
# Load some of the help topics from files. Note that topics which reproduce API
761
775
# details will tend to skew (quickly usually!) so please seek other solutions
768
782
                        'Types of conflicts and what to do about them')
769
783
topic_registry.register('debug-flags', _load_from_file,
770
784
                        'Options to show or record debug information')
771
 
topic_registry.register('location-alias', _load_from_file,
772
 
                        'Aliases for remembered locations')
773
785
topic_registry.register('log-formats', _load_from_file,
774
786
                        'Details on the logging formats available')
 
787
topic_registry.register('url-special-chars', _load_from_file,
 
788
                        'Special character handling in URLs')
775
789
 
776
790
 
777
791
# Register concept topics.
836
850
            return []
837
851
 
838
852
 
 
853
def _format_see_also(see_also):
 
854
    result = ''
 
855
    if see_also:
 
856
        result += '\n:See also: '
 
857
        result += ', '.join(sorted(set(see_also)))
 
858
        result += '\n'
 
859
    return result
 
860
 
 
861
 
839
862
class RegisteredTopic(object):
840
863
    """A help topic which has been registered in the HelpTopicRegistry.
841
864
 
859
882
            returned instead of plain text.
860
883
        """
861
884
        result = topic_registry.get_detail(self.topic)
862
 
        # there is code duplicated here and in bzrlib/plugin.py's
863
 
        # matching Topic code. This should probably be factored in
864
 
        # to a helper function and a common base class.
865
 
        if additional_see_also is not None:
866
 
            see_also = sorted(set(additional_see_also))
867
 
        else:
868
 
            see_also = None
869
 
        if see_also:
870
 
            result += '\n:See also: '
871
 
            result += ', '.join(see_also)
872
 
            result += '\n'
 
885
        result += _format_see_also(additional_see_also)
873
886
        if plain:
874
887
            result = help_as_plain_text(result)
 
888
        i18n.install()
 
889
        result = i18n.gettext_per_paragraph(result)
875
890
        return result
876
891
 
877
892
    def get_help_topic(self):
892
907
        elif line.endswith('::'):
893
908
            line = line[:-1]
894
909
        # Map :doc:`xxx-help` to ``bzr help xxx``
895
 
        line = re.sub(":doc:`(.+)-help`", r'``bzr help \1``', line)
 
910
        line = re.sub(":doc:`(.+?)-help`", r'``bzr help \1``', line)
896
911
        result.append(line)
897
912
    return "\n".join(result) + "\n"
 
913
 
 
914
 
 
915
class ConfigOptionHelpIndex(object):
 
916
    """A help index that returns help topics for config options."""
 
917
 
 
918
    def __init__(self):
 
919
        self.prefix = 'configuration/'
 
920
 
 
921
    def get_topics(self, topic):
 
922
        """Search for topic in the registered config options.
 
923
 
 
924
        :param topic: A topic to search for.
 
925
        :return: A list which is either empty or contains a single
 
926
            config.Option entry.
 
927
        """
 
928
        if topic is None:
 
929
            return []
 
930
        elif topic.startswith(self.prefix):
 
931
            topic = topic[len(self.prefix):]
 
932
        if topic in config.option_registry:
 
933
            return [config.option_registry.get(topic)]
 
934
        else:
 
935
            return []
 
936
 
 
937