bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
2070.4.3
by John Arbash Meinel
code and doc cleanup |
1 |
# Copyright (C) 2006 by 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 |
||
23 |
import sys |
|
24 |
||
25 |
||
|
2070.4.2
by John Arbash Meinel
cleanup help_topics.py |
26 |
_HELP_TOPICS={} |
27 |
||
|
2023.1.2
by ghigo
add help topics module |
28 |
|
29 |
def add_topic(name, obj, comment): |
|
|
2070.4.2
by John Arbash Meinel
cleanup help_topics.py |
30 |
"""add a new topic, obj can be a function or a text; comment is a text""" |
31 |
_HELP_TOPICS[name]=(obj, comment) |
|
|
2023.1.2
by ghigo
add help topics module |
32 |
|
33 |
||
34 |
def write_topic(name, outfile=sys.stdout): |
|
35 |
"""write to outfile the topic named "name""" |
|
|
2070.4.2
by John Arbash Meinel
cleanup help_topics.py |
36 |
obj, comment = _HELP_TOPICS[name] |
|
2023.1.2
by ghigo
add help topics module |
37 |
if callable(obj): |
38 |
obj(name, outfile) |
|
39 |
else: |
|
40 |
outfile.write(obj) |
|
41 |
||
42 |
||
43 |
def is_topic(name): |
|
44 |
"""is "name" a topic ?""" |
|
|
2070.4.2
by John Arbash Meinel
cleanup help_topics.py |
45 |
return name in _HELP_TOPICS |
|
2023.1.2
by ghigo
add help topics module |
46 |
|
47 |
||
48 |
def get_topics_list( ): |
|
49 |
"""return a dict like {topic_name:topi_comment}""" |
|
|
2070.4.2
by John Arbash Meinel
cleanup help_topics.py |
50 |
return _HELP_TOPICS |
|
2023.1.2
by ghigo
add help topics module |
51 |
|
52 |
||
53 |
#----------------------------------------------------
|
|
54 |
||
55 |
def _help_on_topics(name, outfile): |
|
56 |
"""Write out the help for topics to outfile""" |
|
57 |
||
58 |
topics = get_topics_list() |
|
|
2070.4.2
by John Arbash Meinel
cleanup help_topics.py |
59 |
lmax = max(len(topic) for topic in topics) |
|
2023.1.4
by ghigo
the ''bzr help topics'' output is shorter |
60 |
|
|
2023.1.2
by ghigo
add help topics module |
61 |
for topic in topics: |
62 |
obj, comment = topics[topic] |
|
|
2070.4.2
by John Arbash Meinel
cleanup help_topics.py |
63 |
spaces = " " * (lmax-len(topic)) |
|
2023.1.4
by ghigo
the ''bzr help topics'' output is shorter |
64 |
outfile.write("%s%s %s\n" % (topic, spaces, comment)) |
|
2023.1.2
by ghigo
add help topics module |
65 |
|
66 |
||
67 |
def _help_on_revisionspec(name, outfile): |
|
68 |
"""Write out the help for revison spec information""" |
|
69 |
import bzrlib.revisionspec |
|
70 |
||
|
2070.4.2
by John Arbash Meinel
cleanup help_topics.py |
71 |
outfile.write("\nRevision prefix specifier:" |
72 |
"\n--------------------------\n") |
|
|
2023.1.2
by ghigo
add help topics module |
73 |
|
74 |
for i in bzrlib.revisionspec.SPEC_TYPES: |
|
75 |
doc = i.__doc__ |
|
76 |
if doc == bzrlib.revisionspec.RevisionSpec.__doc__: |
|
77 |
doc = "N/A\n" |
|
|
2070.4.2
by John Arbash Meinel
cleanup help_topics.py |
78 |
while (doc[-2:] == '\n\n' or doc[-1:] == ' '): |
|
2023.1.2
by ghigo
add help topics module |
79 |
doc = doc[:-1] |
80 |
||
81 |
outfile.write(" %s %s\n\n" % (i.prefix, doc)) |
|
82 |
||
83 |
||
84 |
_basic_help= \ |
|
85 |
"""Bazaar -- a free distributed version-control tool
|
|
86 |
http://bazaar-vcs.org/
|
|
87 |
||
88 |
Basic commands:
|
|
89 |
||
90 |
bzr init makes this directory a versioned branch
|
|
91 |
bzr branch make a copy of another branch
|
|
92 |
||
93 |
bzr add make files or directories versioned
|
|
94 |
bzr ignore ignore a file or pattern
|
|
95 |
bzr mv move or rename a versioned file
|
|
96 |
||
97 |
bzr status summarize changes in working copy
|
|
98 |
bzr diff show detailed diffs
|
|
99 |
||
100 |
bzr merge pull in changes from another branch
|
|
101 |
bzr commit save some or all changes
|
|
102 |
||
103 |
bzr log show history of changes
|
|
104 |
bzr check validate storage
|
|
105 |
||
106 |
bzr help init more help on e.g. init command
|
|
107 |
bzr help commands list all commands
|
|
108 |
bzr help topics list all help topics
|
|
109 |
"""
|
|
110 |
||
111 |
||
112 |
add_topic("revisionspec", _help_on_revisionspec, "Revisions specifier") |
|
113 |
add_topic("basic", _basic_help, "Basic commands") |
|
114 |
add_topic("topics", _help_on_topics, "Topics list") |