1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
# Copyright (C) 2004, 2005 by Canonical Ltd
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
global_help = \
"""Bazaar-NG -- a free distributed version-control tool
http://bazaar-ng.org/
**WARNING: THIS IS AN UNSTABLE DEVELOPMENT VERSION**
* Metadata format is not stable yet -- you may need to
discard history in the future.
* Many commands unimplemented or partially implemented.
* Space-inefficient storage.
* No merge operators yet.
To make a branch, use 'bzr init' in an existing directory, then 'bzr
add' to make files versioned. 'bzr add .' will recursively add all
non-ignored files.
'bzr status' describes files that are unknown, ignored, or modified.
'bzr diff' shows the text changes to the tree or named files.
'bzr commit -m <MESSAGE>' commits all changes in that branch.
'bzr move' and 'bzr rename' allow you to rename files or directories.
'bzr remove' makes a file unversioned but keeps the working copy;
to delete that too simply delete the file.
'bzr log' shows a history of changes, and
'bzr info' gives summary statistical information.
'bzr check' validates all files are stored safely.
Files can be ignored by giving a path or a glob in .bzrignore at the
top of the tree. Use 'bzr ignored' to see what files are ignored and
why, and 'bzr unknowns' to see files that are neither versioned or
ignored.
For more help on any command, type 'bzr help COMMAND', or 'bzr help
commands' for a list.
"""
def help(topic=None):
if topic == None:
print global_help
elif topic == 'commands':
help_commands()
else:
help_on_command(topic)
def command_usage(cmdname, cmdclass):
"""Return single-line grammar for command.
Only describes arguments, not options.
"""
s = cmdname + ' '
for aname in cmdclass.takes_args:
aname = aname.upper()
if aname[-1] in ['$', '+']:
aname = aname[:-1] + '...'
elif aname[-1] == '?':
aname = '[' + aname[:-1] + ']'
elif aname[-1] == '*':
aname = '[' + aname[:-1] + '...]'
s += aname + ' '
assert s[-1] == ' '
s = s[:-1]
return s
def help_on_command(cmdname):
cmdname = str(cmdname)
from inspect import getdoc
import commands
topic, cmdclass = commands.get_cmd_class(cmdname)
doc = getdoc(cmdclass)
if doc == None:
raise NotImplementedError("sorry, no detailed help yet for %r" % cmdname)
print 'usage:', command_usage(topic, cmdclass)
if cmdclass.aliases:
print 'aliases: ' + ', '.join(cmdclass.aliases)
print doc
help_on_option(cmdclass.takes_options)
def help_on_option(options):
import commands
if not options:
return
print
print 'options:'
for on in options:
l = ' --' + on
for shortname, longname in commands.SHORT_OPTIONS.items():
if longname == on:
l += ', -' + shortname
break
print l
def help_commands():
"""List all commands"""
import inspect
import commands
accu = []
for cmdname, cmdclass in commands.get_all_cmds():
accu.append((cmdname, cmdclass))
accu.sort()
for cmdname, cmdclass in accu:
if cmdclass.hidden:
continue
print command_usage(cmdname, cmdclass)
help = inspect.getdoc(cmdclass)
if help:
print " " + help.split('\n', 1)[0]
|