2070.4.5
by John Arbash Meinel
cleanup copyright line |
1 |
# Copyright (C) 2006 Canonical Ltd
|
2023.1.2
by ghigo
add help topics module |
2 |
#
|
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.
|
|
7 |
#
|
|
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.
|
|
12 |
#
|
|
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
|
|
16 |
||
17 |
"""A collection of extra help information for using bzr.
|
|
18 |
||
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.
|
|
21 |
"""
|
|
22 |
||
2070.4.13
by John Arbash Meinel
Switch help_topics to use a Registry. |
23 |
from bzrlib import registry |
24 |
||
25 |
||
26 |
class HelpTopicRegistry(registry.Registry): |
|
2070.4.15
by John Arbash Meinel
Fixes from Martin |
27 |
"""A Registry customized for handling help topics."""
|
2070.4.13
by John Arbash Meinel
Switch help_topics to use a Registry. |
28 |
|
29 |
def register(self, topic, detail, summary): |
|
30 |
"""Register a new help topic.
|
|
31 |
||
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.
|
|
37 |
"""
|
|
38 |
# The detail is stored as the 'object' and the
|
|
39 |
super(HelpTopicRegistry, self).register(topic, detail, info=summary) |
|
40 |
||
41 |
def register_lazy(self, topic, module_name, member_name, summary): |
|
42 |
"""Register a new help topic, and import the details on demand.
|
|
43 |
||
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.
|
|
48 |
"""
|
|
2070.4.15
by John Arbash Meinel
Fixes from Martin |
49 |
super(HelpTopicRegistry, self).register_lazy(topic, module_name, |
50 |
member_name, info=summary) |
|
2070.4.13
by John Arbash Meinel
Switch help_topics to use a Registry. |
51 |
|
52 |
def get_detail(self, topic): |
|
53 |
"""Get the detailed help on a given topic."""
|
|
54 |
obj = self.get(topic) |
|
55 |
if callable(obj): |
|
56 |
return obj(topic) |
|
57 |
else: |
|
58 |
return obj |
|
59 |
||
60 |
def get_summary(self, topic): |
|
61 |
"""Get the single line summary for the topic."""
|
|
62 |
return self.get_info(topic) |
|
63 |
||
64 |
||
65 |
topic_registry = HelpTopicRegistry() |
|
2023.1.2
by ghigo
add help topics module |
66 |
|
67 |
||
68 |
#----------------------------------------------------
|
|
69 |
||
2070.4.13
by John Arbash Meinel
Switch help_topics to use a Registry. |
70 |
def _help_on_topics(dummy): |
2023.1.2
by ghigo
add help topics module |
71 |
"""Write out the help for topics to outfile"""
|
72 |
||
2070.4.13
by John Arbash Meinel
Switch help_topics to use a Registry. |
73 |
topics = topic_registry.keys() |
2070.4.2
by John Arbash Meinel
cleanup help_topics.py |
74 |
lmax = max(len(topic) for topic in topics) |
2023.1.4
by ghigo
the ''bzr help topics'' output is shorter |
75 |
|
2070.4.13
by John Arbash Meinel
Switch help_topics to use a Registry. |
76 |
out = [] |
2023.1.2
by ghigo
add help topics module |
77 |
for topic in topics: |
2070.4.13
by John Arbash Meinel
Switch help_topics to use a Registry. |
78 |
summary = topic_registry.get_summary(topic) |
79 |
out.append("%-*s %s\n" % (lmax, topic, summary)) |
|
80 |
return ''.join(out) |
|
81 |
||
82 |
||
83 |
def _help_on_revisionspec(name): |
|
2376.4.34
by Jonathan Lange
Remove spurious quote mark in docstring. |
84 |
"""Write the summary help for all documented topics to outfile."""
|
2023.1.2
by ghigo
add help topics module |
85 |
import bzrlib.revisionspec |
86 |
||
2070.4.13
by John Arbash Meinel
Switch help_topics to use a Registry. |
87 |
out = [] |
88 |
out.append("\nRevision prefix specifier:" |
|
89 |
"\n--------------------------\n") |
|
2023.1.2
by ghigo
add help topics module |
90 |
|
91 |
for i in bzrlib.revisionspec.SPEC_TYPES: |
|
2070.4.14
by John Arbash Meinel
Switch revisionspec to use the help defined as help_txt rather than the doc string |
92 |
doc = i.help_txt |
93 |
if doc == bzrlib.revisionspec.RevisionSpec.help_txt: |
|
2023.1.2
by ghigo
add help topics module |
94 |
doc = "N/A\n" |
2070.4.2
by John Arbash Meinel
cleanup help_topics.py |
95 |
while (doc[-2:] == '\n\n' or doc[-1:] == ' '): |
2023.1.2
by ghigo
add help topics module |
96 |
doc = doc[:-1] |
97 |
||
2070.4.13
by John Arbash Meinel
Switch help_topics to use a Registry. |
98 |
out.append(" %s %s\n\n" % (i.prefix, doc)) |
99 |
||
100 |
return ''.join(out) |
|
2023.1.2
by ghigo
add help topics module |
101 |
|
2241.2.11
by ghigo
On the basis of Robert Collins and John Arbash Meinel |
102 |
|
2241.2.5
by ghigo
add the topics transport |
103 |
def _help_on_transport(name): |
104 |
from bzrlib.transport import ( |
|
105 |
transport_list_registry, |
|
106 |
)
|
|
107 |
import textwrap |
|
108 |
||
109 |
def add_string(proto, help, maxl, prefix_width=20): |
|
110 |
help_lines = textwrap.wrap(help, maxl - prefix_width) |
|
111 |
line_with_indent = '\n' + ' ' * prefix_width |
|
112 |
help_text = line_with_indent.join(help_lines) |
|
113 |
return "%-20s%s\n" % (proto, help_text) |
|
114 |
||
2241.2.8
by ghigo
- rename transport urlspec |
115 |
def sort_func(a,b): |
116 |
a1 = a[:a.rfind("://")] |
|
117 |
b1 = b[:b.rfind("://")] |
|
118 |
if a1>b1: |
|
119 |
return +1 |
|
120 |
elif a1<b1: |
|
121 |
return -1 |
|
122 |
else: |
|
123 |
return 0 |
|
124 |
||
2241.2.6
by ghigo
removed unused code |
125 |
out = [] |
2241.2.5
by ghigo
add the topics transport |
126 |
protl = [] |
127 |
decl = [] |
|
128 |
protos = transport_list_registry.keys( ) |
|
2241.2.8
by ghigo
- rename transport urlspec |
129 |
protos.sort(sort_func) |
2241.2.5
by ghigo
add the topics transport |
130 |
for proto in protos: |
131 |
shorthelp = transport_list_registry.get_help(proto) |
|
132 |
if not shorthelp: |
|
133 |
continue
|
|
134 |
if proto.endswith("://"): |
|
135 |
protl.extend(add_string(proto, shorthelp, 79)) |
|
136 |
else: |
|
137 |
decl.extend(add_string(proto, shorthelp, 79)) |
|
138 |
||
139 |
||
2241.2.11
by ghigo
On the basis of Robert Collins and John Arbash Meinel |
140 |
out = "\nSupported URL prefix\n--------------------\n" + \ |
141 |
''.join(protl) |
|
142 |
||
143 |
if len(decl): |
|
144 |
out += "\nSupported modifiers\n-------------------\n" + \ |
|
145 |
''.join(decl) |
|
2241.2.5
by ghigo
add the topics transport |
146 |
|
147 |
return out |
|
148 |
||
2023.1.2
by ghigo
add help topics module |
149 |
|
150 |
_basic_help= \ |
|
151 |
"""Bazaar -- a free distributed version-control tool
|
|
152 |
http://bazaar-vcs.org/
|
|
153 |
||
154 |
Basic commands:
|
|
155 |
bzr init makes this directory a versioned branch
|
|
156 |
bzr branch make a copy of another branch
|
|
157 |
||
158 |
bzr add make files or directories versioned
|
|
159 |
bzr ignore ignore a file or pattern
|
|
160 |
bzr mv move or rename a versioned file
|
|
161 |
||
162 |
bzr status summarize changes in working copy
|
|
163 |
bzr diff show detailed diffs
|
|
164 |
||
165 |
bzr merge pull in changes from another branch
|
|
166 |
bzr commit save some or all changes
|
|
167 |
||
168 |
bzr log show history of changes
|
|
169 |
bzr check validate storage
|
|
170 |
||
171 |
bzr help init more help on e.g. init command
|
|
172 |
bzr help commands list all commands
|
|
173 |
bzr help topics list all help topics
|
|
174 |
"""
|
|
175 |
||
176 |
||
1551.9.32
by Aaron Bentley
Add global option help |
177 |
_global_options =\ |
178 |
"""Global Options
|
|
179 |
||
180 |
These options may be used with any command, and may appear in front of any
|
|
181 |
command. (e.g. "bzr --quiet help").
|
|
182 |
||
183 |
--quiet Suppress informational output; only print errors and warnings
|
|
184 |
--version Print the version number
|
|
185 |
||
186 |
--no-aliases Do not process command aliases when running this command
|
|
187 |
--builtin Use the built-in version of a command, not the plugin version.
|
|
188 |
This does not suppress other plugin effects
|
|
189 |
--no-plugins Do not process any plugins
|
|
190 |
||
2247.1.1
by John Arbash Meinel
fix --Derror => -Derror (trivial) |
191 |
-Derror Instead of normal error handling, always print a traceback on
|
1551.9.32
by Aaron Bentley
Add global option help |
192 |
error.
|
193 |
--profile Profile execution using the hotshot profiler
|
|
194 |
--lsprof Profile execution using the lsprof profiler
|
|
195 |
--lsprof-file Profile execution using the lsprof profiler, and write the
|
|
2493.2.7
by Aaron Bentley
Add info to --lsprof-file entry in global options |
196 |
results to a specified file. If the filename ends with ".txt",
|
2654.2.1
by Ian Clatworthy
Dump profiling data for KCacheGrind if the filename starts with callgrind.out |
197 |
text format will be used. If the filename either starts with
|
198 |
"callgrind.out" or end with ".callgrind", the output will be
|
|
199 |
formatted for use with KCacheGrind. Otherwise, the output
|
|
200 |
will be a pickle.
|
|
2493.2.7
by Aaron Bentley
Add info to --lsprof-file entry in global options |
201 |
|
202 |
See doc/developers/profiling.txt for more information on profiling.
|
|
1551.9.32
by Aaron Bentley
Add global option help |
203 |
|
204 |
Note: --version must be supplied before any command.
|
|
205 |
"""
|
|
206 |
||
2245.7.1
by James Westby
Add a help topic describing checkouts and how they work. |
207 |
_checkouts = \ |
208 |
"""Checkouts
|
|
209 |
||
2245.7.2
by James Westby
Update the checkouts help topic with the comments from Aaron. |
210 |
Checkouts are source trees that are connected to a branch, so that when
|
211 |
you commit in the source tree, the commit goes into that branch. They
|
|
212 |
allow you to use a simpler, more centralized workflow, ignoring some of
|
|
213 |
Bazaar's decentralized features until you want them. Using checkouts
|
|
214 |
with shared repositories is very similar to working with SVN or CVS, but
|
|
215 |
doesn't have the same restrictions. And using checkouts still allows
|
|
216 |
others working on the project to use whatever workflow they like.
|
|
2245.7.1
by James Westby
Add a help topic describing checkouts and how they work. |
217 |
|
218 |
A checkout is created with the bzr checkout command (see "help checkout").
|
|
2245.7.2
by James Westby
Update the checkouts help topic with the comments from Aaron. |
219 |
You pass it a reference to another branch, and it will create a local copy
|
2245.7.1
by James Westby
Add a help topic describing checkouts and how they work. |
220 |
for you that still contains a reference to the branch you created the
|
2245.7.2
by James Westby
Update the checkouts help topic with the comments from Aaron. |
221 |
checkout from (the master branch). Then if you make any commits they will be
|
222 |
made on the other branch first. This creates an instant mirror of your work, or
|
|
223 |
facilitates lockstep development, where each developer is working together,
|
|
224 |
continuously integrating the changes of others.
|
|
2245.7.1
by James Westby
Add a help topic describing checkouts and how they work. |
225 |
|
226 |
However the checkout is still a first class branch in Bazaar terms, so that
|
|
2245.7.2
by James Westby
Update the checkouts help topic with the comments from Aaron. |
227 |
you have the full history locally. As you have a first class branch you can
|
228 |
also commit locally if you want, for instance due to the temporary loss af a
|
|
229 |
network connection. Use the --local option to commit to do this. All the local
|
|
230 |
commits will then be made on the master branch the next time you do a non-local
|
|
231 |
commit.
|
|
2245.7.1
by James Westby
Add a help topic describing checkouts and how they work. |
232 |
|
233 |
If you are using a checkout from a shared branch you will periodically want to
|
|
234 |
pull in all the changes made by others. This is done using the "update"
|
|
2245.7.2
by James Westby
Update the checkouts help topic with the comments from Aaron. |
235 |
command. The changes need to be applied before any non-local commit, but
|
236 |
Bazaar will tell you if there are any changes and suggest that you use this
|
|
237 |
command when needed.
|
|
2245.7.1
by James Westby
Add a help topic describing checkouts and how they work. |
238 |
|
239 |
It is also possible to create a "lightweight" checkout by passing the
|
|
240 |
--lightweight flag to checkout. A lightweight checkout is even closer to an
|
|
241 |
SVN checkout in that it is not a first class branch, it mainly consists of the
|
|
242 |
working tree. This means that any history operations must query the master
|
|
243 |
branch, which could be slow if a network connection is involved. Also, as you
|
|
244 |
don't have a local branch, then you cannot commit locally.
|
|
245 |
||
2374.1.1
by Ian Clatworthy
Help and man page fixes |
246 |
Lightweight checkouts work best when you have fast reliable access to the
|
2245.7.2
by James Westby
Update the checkouts help topic with the comments from Aaron. |
247 |
master branch. This means that if the master branch is on the same disk or LAN
|
248 |
a lightweight checkout will be faster than a heavyweight one for any commands
|
|
249 |
that modify the revision history (as only one copy branch needs to be updated).
|
|
250 |
Heavyweight checkouts will generally be faster for any command that uses the
|
|
251 |
history but does not change it, but if the master branch is on the same disk
|
|
252 |
then there wont be a noticeable difference.
|
|
253 |
||
254 |
Another possible use for a checkout is to use it with a treeless repository
|
|
2370.1.2
by Ian Clatworthy
Minor fixes to help on checkouts |
255 |
containing your branches, where you maintain only one working tree by
|
2245.7.2
by James Westby
Update the checkouts help topic with the comments from Aaron. |
256 |
switching the master branch that the checkout points to when you want to
|
257 |
work on a different branch.
|
|
258 |
||
2245.7.1
by James Westby
Add a help topic describing checkouts and how they work. |
259 |
Obviously to commit on a checkout you need to be able to write to the master
|
2370.1.2
by Ian Clatworthy
Minor fixes to help on checkouts |
260 |
branch. This means that the master branch must be accessible over a writeable
|
2245.7.2
by James Westby
Update the checkouts help topic with the comments from Aaron. |
261 |
protocol , such as sftp://, and that you have write permissions at the other
|
262 |
end. Checkouts also work on the local file system, so that all that matters is
|
|
263 |
file permissions.
|
|
2245.7.1
by James Westby
Add a help topic describing checkouts and how they work. |
264 |
|
265 |
You can change the master of a checkout by using the "bind" command (see "help
|
|
266 |
bind"). This will change the location that the commits are sent to. The bind
|
|
2245.7.2
by James Westby
Update the checkouts help topic with the comments from Aaron. |
267 |
command can also be used to turn a branch into a heavy checkout. If you
|
268 |
would like to convert your heavy checkout into a normal branch so that every
|
|
269 |
commit is local, you can use the "unbind" command.
|
|
2245.7.1
by James Westby
Add a help topic describing checkouts and how they work. |
270 |
|
2245.7.2
by James Westby
Update the checkouts help topic with the comments from Aaron. |
271 |
Related commands:
|
2245.7.1
by James Westby
Add a help topic describing checkouts and how they work. |
272 |
|
273 |
checkout Create a checkout. Pass --lightweight to get a lightweight
|
|
274 |
checkout
|
|
275 |
update Pull any changes in the master branch in to your checkout
|
|
276 |
commit Make a commit that is sent to the master branch. If you have
|
|
277 |
a heavy checkout then the --local option will commit to the
|
|
278 |
checkout without sending the commit to the master
|
|
279 |
bind Change the master branch that the commits in the checkout will
|
|
280 |
be sent to
|
|
281 |
unbind Turn a heavy checkout into a standalone branch so that any
|
|
282 |
commits are only made locally
|
|
283 |
"""
|
|
284 |
||
2401.2.1
by James Westby
Add a help topic for repositories. |
285 |
_repositories = \ |
286 |
"""Repositories
|
|
287 |
||
2604.2.1
by Robert Collins
(robertc) Introduce a pack command. |
288 |
Repositories in Bazaar are where committed information is stored. There is
|
289 |
a repository associated with every branch.
|
|
290 |
||
291 |
Repositories are a form of database. Bzr will usually maintain this for
|
|
292 |
good performance automatically, but in some situations (e.g. when doing
|
|
293 |
very many commits in a short time period) you may want to ask bzr to
|
|
294 |
optimise the database indices. This can be done by the 'bzr pack' command.
|
|
295 |
||
296 |
By default just running 'bzr init' will create a repository within the new
|
|
297 |
branch but it is possible to create a shared repository which allows multiple
|
|
298 |
branches to share their information in the same location. When a new branch is
|
|
299 |
created it will first look to see if there is a containing shared repository it
|
|
300 |
can use.
|
|
2485.1.2
by James Westby
Update with comments from review, thanks to John and Aaron. |
301 |
|
302 |
When two branches of the same project share a repository, there is
|
|
303 |
generally a large space saving. For some operations (e.g. branching
|
|
304 |
within the repository) this translates in to a large time saving.
|
|
2401.2.1
by James Westby
Add a help topic for repositories. |
305 |
|
306 |
To create a shared repository use the init-repository command (or the alias
|
|
2485.1.2
by James Westby
Update with comments from review, thanks to John and Aaron. |
307 |
init-repo). This command takes the location of the repository to create. This
|
308 |
means that 'bzr init-repository repo' will create a directory named 'repo',
|
|
309 |
which contains a shared repository. Any new branches that are created in this
|
|
310 |
directory will then use it for storage.
|
|
2401.2.1
by James Westby
Add a help topic for repositories. |
311 |
|
312 |
It is a good idea to create a repository whenever you might create more
|
|
313 |
than one branch of a project. This is true for both working areas where you
|
|
314 |
are doing the development, and any server areas that you use for hosting
|
|
2485.1.2
by James Westby
Update with comments from review, thanks to John and Aaron. |
315 |
projects. In the latter case, it is common to want branches without working
|
316 |
trees. Since the files in the branch will not be edited directly there is no
|
|
317 |
need to use up disk space for a working tree. To create a repository in which
|
|
318 |
the branches will not have working trees pass the '--no-trees' option to
|
|
319 |
'init-repository'.
|
|
2401.2.1
by James Westby
Add a help topic for repositories. |
320 |
|
321 |
Related commands:
|
|
322 |
||
323 |
init-repository Create a shared repository. Use --no-trees to create one
|
|
2485.1.2
by James Westby
Update with comments from review, thanks to John and Aaron. |
324 |
in which new branches won't get a working tree.
|
2401.2.1
by James Westby
Add a help topic for repositories. |
325 |
"""
|
326 |
||
2485.1.2
by James Westby
Update with comments from review, thanks to John and Aaron. |
327 |
|
2401.2.2
by James Westby
Add a working-trees help topic. |
328 |
_working_trees = \ |
329 |
"""Working Trees
|
|
330 |
||
2485.1.2
by James Westby
Update with comments from review, thanks to John and Aaron. |
331 |
A working tree is the contents of a branch placed on disk so that you can
|
2401.2.2
by James Westby
Add a working-trees help topic. |
332 |
see the files and edit them. The working tree is where you make changes to a
|
333 |
branch, and when you commit the current state of the working tree is the
|
|
334 |
snapshot that is recorded in the commit.
|
|
335 |
||
2485.1.2
by James Westby
Update with comments from review, thanks to John and Aaron. |
336 |
When you push a branch to a remote system, a working tree will not be
|
337 |
created. If one is already present the files will not be updated. The
|
|
338 |
branch information will be updated and the working tree will be marked
|
|
339 |
as out-of-date. Updating a working tree remotely is difficult, as there
|
|
340 |
may be uncommitted changes or the update may cause content conflicts that are
|
|
341 |
difficult to deal with remotely.
|
|
2401.2.2
by James Westby
Add a working-trees help topic. |
342 |
|
343 |
If you have a branch with no working tree you can use the 'checkout' command
|
|
344 |
to create a working tree. If you run 'bzr checkout .' from the branch it will
|
|
2485.1.2
by James Westby
Update with comments from review, thanks to John and Aaron. |
345 |
create the working tree. If the branch is updated remotely, you can update the
|
346 |
working tree by running 'bzr update' in that directory.
|
|
2401.2.2
by James Westby
Add a working-trees help topic. |
347 |
|
348 |
If you have a branch with a working tree that you do not want the 'remove-tree'
|
|
349 |
command will remove the tree if it is safe. This can be done to avoid the
|
|
350 |
warning about the remote working tree not being updated when pushing to the
|
|
351 |
branch. It can also be useful when working with a '--no-trees' repository
|
|
352 |
(see 'bzr help repositories').
|
|
353 |
||
354 |
If you want to have a working tree on a remote machine that you push to you
|
|
355 |
can either run 'bzr update' in the remote branch after each push, or use some
|
|
356 |
other method to update the tree during the push. There is an 'rspush' plugin
|
|
357 |
that will update the working tree using rsync as well as doing a push. There
|
|
358 |
is also a 'push-and-update' plugin that automates running 'bzr update' via SSH
|
|
359 |
after each push.
|
|
360 |
||
361 |
Useful commands:
|
|
362 |
||
363 |
checkout Create a working tree when a branch does not have one.
|
|
364 |
remove-tree Removes the working tree from a branch when it is safe to do so.
|
|
365 |
update When a working tree is out of sync with it's associated branch
|
|
366 |
this will update the tree to match the branch.
|
|
367 |
"""
|
|
368 |
||
2520.1.1
by Daniel Watkins
Added 'help status-flags'. |
369 |
_status_flags = \ |
370 |
"""Status Flags
|
|
371 |
||
372 |
Status flags are used to summarise changes to the working tree in a concise
|
|
373 |
manner. They are in the form:
|
|
374 |
xxx <filename>
|
|
375 |
where the columns' meanings are as follows.
|
|
376 |
||
377 |
Column 1: versioning / renames
|
|
378 |
+ File versioned
|
|
379 |
- File unversioned
|
|
380 |
R File renamed
|
|
381 |
? File unknown
|
|
382 |
C File has conflicts
|
|
383 |
P Entry for a pending merge (not a file)
|
|
384 |
||
385 |
Column 2: Contents
|
|
386 |
N File created
|
|
387 |
D File deleted
|
|
388 |
K File kind changed
|
|
389 |
M File modified
|
|
390 |
||
391 |
Column 3: Execute
|
|
392 |
* The execute bit was changed
|
|
393 |
"""
|
|
394 |
||
1551.9.32
by Aaron Bentley
Add global option help |
395 |
|
2070.4.13
by John Arbash Meinel
Switch help_topics to use a Registry. |
396 |
topic_registry.register("revisionspec", _help_on_revisionspec, |
397 |
"Explain how to use --revision") |
|
398 |
topic_registry.register('basic', _basic_help, "Basic commands") |
|
399 |
topic_registry.register('topics', _help_on_topics, "Topics list") |
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
400 |
def get_format_topic(topic): |
2204.4.7
by Aaron Bentley
restore register_lazy, remove register_factory, other updates |
401 |
from bzrlib import bzrdir |
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
402 |
return bzrdir.format_registry.help_topic(topic) |
2204.4.10
by Aaron Bentley
Capitalize 'D' in 'directory formats' |
403 |
topic_registry.register('formats', get_format_topic, 'Directory formats') |
1551.9.34
by Aaron Bentley
Fix NEWS and whitespace |
404 |
topic_registry.register('global-options', _global_options, |
1551.9.32
by Aaron Bentley
Add global option help |
405 |
'Options that can be used with any command') |
2245.7.1
by James Westby
Add a help topic describing checkouts and how they work. |
406 |
topic_registry.register('checkouts', _checkouts, |
407 |
'Information on what a checkout is') |
|
2241.2.8
by ghigo
- rename transport urlspec |
408 |
topic_registry.register('urlspec', _help_on_transport, |
2241.2.5
by ghigo
add the topics transport |
409 |
"Supported transport protocols") |
2520.1.1
by Daniel Watkins
Added 'help status-flags'. |
410 |
topic_registry.register('status-flags', _status_flags, |
411 |
"Help on status flags") |
|
2376.4.36
by Jonathan Lange
Provide really basic help topic for our bug tracker support. |
412 |
def get_bugs_topic(topic): |
413 |
from bzrlib import bugtracker |
|
414 |
return bugtracker.tracker_registry.help_topic(topic) |
|
415 |
topic_registry.register('bugs', get_bugs_topic, 'Bug tracker support') |
|
2401.2.1
by James Westby
Add a help topic for repositories. |
416 |
topic_registry.register('repositories', _repositories, |
417 |
'Basic information on shared repositories.') |
|
2401.2.2
by James Westby
Add a working-trees help topic. |
418 |
topic_registry.register('working-trees', _working_trees, |
419 |
'Information on working trees') |
|
2245.7.1
by James Westby
Add a help topic describing checkouts and how they work. |
420 |
|
2432.1.1
by Robert Collins
Add a HelpTopicContext object. |
421 |
|
2432.1.15
by Robert Collins
Rename Context (in bzrlib.help) to Index, for a clearer name. |
422 |
class HelpTopicIndex(object): |
423 |
"""A index for bzr help that returns topics."""
|
|
2432.1.8
by Robert Collins
HelpTopicContext now returns RegisteredTopic objects for get_topics calls. |
424 |
|
2432.1.17
by Robert Collins
Add prefixes to HelpIndexes. |
425 |
def __init__(self): |
426 |
self.prefix = '' |
|
427 |
||
2432.1.8
by Robert Collins
HelpTopicContext now returns RegisteredTopic objects for get_topics calls. |
428 |
def get_topics(self, topic): |
429 |
"""Search for topic in the HelpTopicRegistry.
|
|
430 |
||
431 |
:param topic: A topic to search for. None is treated as 'basic'.
|
|
432 |
:return: A list which is either empty or contains a single
|
|
433 |
RegisteredTopic entry.
|
|
434 |
"""
|
|
435 |
if topic is None: |
|
436 |
topic = 'basic' |
|
437 |
if topic in topic_registry: |
|
438 |
return [RegisteredTopic(topic)] |
|
439 |
else: |
|
440 |
return [] |
|
441 |
||
442 |
||
443 |
class RegisteredTopic(object): |
|
444 |
"""A help topic which has been registered in the HelpTopicRegistry.
|
|
445 |
||
446 |
These topics consist of nothing more than the name of the topic - all
|
|
447 |
data is retrieved on demand from the registry.
|
|
448 |
"""
|
|
449 |
||
450 |
def __init__(self, topic): |
|
451 |
"""Constructor.
|
|
452 |
||
453 |
:param topic: The name of the topic that this represents.
|
|
454 |
"""
|
|
455 |
self.topic = topic |
|
2432.1.10
by Robert Collins
Add get_help_text() to RegisteredTopic to get the help as a string. |
456 |
|
2432.1.22
by Robert Collins
Teach RegisteredTopic to support the additional_see_also list of related help terms. |
457 |
def get_help_text(self, additional_see_also=None): |
458 |
"""Return a string with the help for this topic.
|
|
459 |
||
460 |
:param additional_see_also: Additional help topics to be
|
|
461 |
cross-referenced.
|
|
462 |
"""
|
|
463 |
result = topic_registry.get_detail(self.topic) |
|
2432.1.25
by Robert Collins
Return plugin module docstrings for 'bzr help plugin'. |
464 |
# there is code duplicated here and in bzrlib/plugin.py's
|
465 |
# matching Topic code. This should probably be factored in
|
|
466 |
# to a helper function and a common base class.
|
|
2432.1.22
by Robert Collins
Teach RegisteredTopic to support the additional_see_also list of related help terms. |
467 |
if additional_see_also is not None: |
468 |
see_also = sorted(set(additional_see_also)) |
|
469 |
else: |
|
470 |
see_also = None |
|
471 |
if see_also: |
|
472 |
result += '\nSee also: ' |
|
473 |
result += ', '.join(see_also) |
|
474 |
result += '\n' |
|
475 |
return result |
|
2432.1.27
by Robert Collins
Add a get_help_topic method to RegisteredTopic. |
476 |
|
477 |
def get_help_topic(self): |
|
478 |
"""Return the help topic this can be found under."""
|
|
479 |
return self.topic |
|
2485.1.1
by James Westby
Update the help topics to the latest bzr.dev. |
480 |