1
# Copyright (C) 2006 Canonical Ltd
 
 
3
# This program is free software; you can redistribute it and/or modify
 
 
4
# it under the terms of the GNU General Public License as published by
 
 
5
# the Free Software Foundation; either version 2 of the License, or
 
 
6
# (at your option) any later version.
 
 
8
# This program is distributed in the hope that it will be useful,
 
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
 
11
# GNU General Public License for more details.
 
 
13
# You should have received a copy of the GNU General Public License
 
 
14
# along with this program; if not, write to the Free Software
 
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 
17
"""A collection of extra help information for using bzr.
 
 
19
Help topics are meant to be help for items that aren't commands, but will
 
 
20
help bzr become fully learnable without referring to a tutorial.
 
 
23
from bzrlib import registry
 
 
26
class HelpTopicRegistry(registry.Registry):
 
 
27
    """A Registry customized for handling help topics."""
 
 
29
    def register(self, topic, detail, summary):
 
 
30
        """Register a new help topic.
 
 
32
        :param topic: Name of documentation entry
 
 
33
        :param detail: Function or string object providing detailed
 
 
34
            documentation for topic.  Function interface is detail(topic).
 
 
35
            This should return a text string of the detailed information.
 
 
36
        :param summary: String providing single-line documentation for topic.
 
 
38
        # The detail is stored as the 'object' and the 
 
 
39
        super(HelpTopicRegistry, self).register(topic, detail, info=summary)
 
 
41
    def register_lazy(self, topic, module_name, member_name, summary):
 
 
42
        """Register a new help topic, and import the details on demand.
 
 
44
        :param topic: Name of documentation entry
 
 
45
        :param module_name: The module to find the detailed help.
 
 
46
        :param member_name: The member of the module to use for detailed help.
 
 
47
        :param summary: String providing single-line documentation for topic.
 
 
49
        super(HelpTopicRegistry, self).register_lazy(topic, module_name,
 
 
50
                                                     member_name, info=summary)
 
 
52
    def get_detail(self, topic):
 
 
53
        """Get the detailed help on a given topic."""
 
 
60
    def get_summary(self, topic):
 
 
61
        """Get the single line summary for the topic."""
 
 
62
        return self.get_info(topic)
 
 
65
topic_registry = HelpTopicRegistry()
 
 
68
#----------------------------------------------------
 
 
70
def _help_on_topics(dummy):
 
 
71
    """Write out the help for topics to outfile"""
 
 
73
    topics = topic_registry.keys()
 
 
74
    lmax = max(len(topic) for topic in topics)
 
 
78
        summary = topic_registry.get_summary(topic)
 
 
79
        out.append("%-*s %s\n" % (lmax, topic, summary))
 
 
83
def _help_on_revisionspec(name):
 
 
84
    """"Write the summary help for all documented topics to outfile."""
 
 
85
    import bzrlib.revisionspec
 
 
88
    out.append("\nRevision prefix specifier:"
 
 
89
               "\n--------------------------\n")
 
 
91
    for i in bzrlib.revisionspec.SPEC_TYPES:
 
 
93
        if doc == bzrlib.revisionspec.RevisionSpec.help_txt:
 
 
95
        while (doc[-2:] == '\n\n' or doc[-1:] == ' '):
 
 
98
        out.append("  %s %s\n\n" % (i.prefix, doc))
 
 
104
"""Bazaar -- a free distributed version-control tool
 
 
105
http://bazaar-vcs.org/
 
 
108
  bzr init           makes this directory a versioned branch
 
 
109
  bzr branch         make a copy of another branch
 
 
111
  bzr add            make files or directories versioned
 
 
112
  bzr ignore         ignore a file or pattern
 
 
113
  bzr mv             move or rename a versioned file
 
 
115
  bzr status         summarize changes in working copy
 
 
116
  bzr diff           show detailed diffs
 
 
118
  bzr merge          pull in changes from another branch
 
 
119
  bzr commit         save some or all changes
 
 
121
  bzr log            show history of changes
 
 
122
  bzr check          validate storage
 
 
124
  bzr help init      more help on e.g. init command
 
 
125
  bzr help commands  list all commands
 
 
126
  bzr help topics    list all help topics
 
 
133
These options may be used with any command, and may appear in front of any
 
 
134
command.  (e.g. "bzr --quiet help").
 
 
136
--quiet        Suppress informational output; only print errors and warnings
 
 
137
--version      Print the version number
 
 
139
--no-aliases   Do not process command aliases when running this command
 
 
140
--builtin      Use the built-in version of a command, not the plugin version.
 
 
141
               This does not suppress other plugin effects
 
 
142
--no-plugins   Do not process any plugins
 
 
144
--Derror       Instead of normal error handling, always print a traceback on
 
 
146
--profile      Profile execution using the hotshot profiler
 
 
147
--lsprof       Profile execution using the lsprof profiler
 
 
148
--lsprof-file  Profile execution using the lsprof profiler, and write the
 
 
149
               results to a specified file.
 
 
151
Note: --version must be supplied before any command.
 
 
157
Checkouts are a way of working with Bazaar that can be quite simple, but also
 
 
158
very useful, as they allow you to ignore some of the features of distributed
 
 
159
version control that Bazaar has until you need them. Using them can give you
 
 
160
a workflow that is very similar to SVN, but still allow others working on
 
 
161
the project to use another workflow, allow you flexibility in your own
 
 
162
workflow, and still provide some of the improvements of Bazaar over SVN to
 
 
165
A checkout is created with the bzr checkout command (see "help checkout").
 
 
166
You pass it a reference to another branch, and it will create a local branch
 
 
167
for you that still contains a reference to the branch you created the
 
 
168
checkout from (the master branch). Then if you commit any changes to your local
 
 
169
branch those commits will be made on the other branch first. This creates an
 
 
170
instant mirror of your work, or facilitates lockstep development, where each
 
 
171
developer is working together, continuously integrating the changes of others.
 
 
173
However the checkout is still a first class branch in Bazaar terms, so that
 
 
174
you have the full history locally, and can branch from it, for example to
 
 
175
work on a feature branch.
 
 
177
As you have a first class branch you can also commit locally if you want,
 
 
178
for instance due to the temporary loss af a network connection. Use the
 
 
179
--local option to commit to do this.
 
 
181
If you are using a checkout from a shared branch you will periodically want to
 
 
182
pull in all the changes made by others. This is done using the "update"
 
 
183
command. The changes need to be pulled before any commit, but Bazaar will tell
 
 
184
you if there are any changes and suggest that you use this command when needed.
 
 
186
It is also possible to create a "lightweight" checkout by passing the
 
 
187
--lightweight flag to checkout. A lightweight checkout is even closer to an
 
 
188
SVN checkout in that it is not a first class branch, it mainly consists of the
 
 
189
working tree. This means that any history operations must query the master
 
 
190
branch, which could be slow if a network connection is involved. Also, as you
 
 
191
don't have a local branch, then you cannot commit locally.
 
 
193
Obviously to commit on a checkout you need to be able to write to the master
 
 
194
branch. This means that there must be a writeable transport in between, such
 
 
195
as sftp://, and that you have write permissions at the other end. Checkouts
 
 
196
also work on the local file system, so that all that matters is file
 
 
199
You can change the master of a checkout by using the "bind" command (see "help
 
 
200
bind"). This will change the location that the commits are sent to. The bind
 
 
201
command can also be used to turn a branch in to a heavy checkout. If you
 
 
202
would like to convert your heavy checkout to a normal branch so that every
 
 
203
commit is local you can use the "unbind" command.
 
 
207
  checkout    Create a checkout. Pass --lightweight to get a lightweight
 
 
209
  update      Pull any changes in the master branch in to your checkout
 
 
210
  commit      Make a commit that is sent to the master branch. If you have
 
 
211
              a heavy checkout then the --local option will commit to the 
 
 
212
              checkout without sending the commit to the master
 
 
213
  bind        Change the master branch that the commits in the checkout will
 
 
215
  unbind      Turn a heavy checkout into a standalone branch so that any
 
 
216
              commits are only made locally
 
 
220
topic_registry.register("revisionspec", _help_on_revisionspec,
 
 
221
                        "Explain how to use --revision")
 
 
222
topic_registry.register('basic', _basic_help, "Basic commands")
 
 
223
topic_registry.register('topics', _help_on_topics, "Topics list")
 
 
224
def get_format_topic(topic):
 
 
225
    from bzrlib import bzrdir
 
 
226
    return bzrdir.format_registry.help_topic(topic)
 
 
227
topic_registry.register('formats', get_format_topic, 'Directory formats')
 
 
228
topic_registry.register('global-options', _global_options,
 
 
229
                        'Options that can be used with any command')
 
 
230
topic_registry.register('checkouts', _checkouts,
 
 
231
                        'Information on what a checkout is')