~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/help.py

  • Committer: Martin Pool
  • Date: 2005-05-05 06:38:18 UTC
  • Revision ID: mbp@sourcefrog.net-20050505063818-3eb3260343878325
- do upload CHANGELOG to web server, even though it's autogenerated

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
* No merge operators yet.
31
31
 
32
 
 
33
 
To make a branch, use 'bzr init' in an existing directory, then 'bzr
34
 
add' to make files versioned.  'bzr add .' will recursively add all
35
 
non-ignored files.
36
 
 
37
 
'bzr status' describes files that are unknown, ignored, or modified.
38
 
'bzr diff' shows the text changes to the tree or named files.
39
 
'bzr commit -m <MESSAGE>' commits all changes in that branch.
40
 
 
41
 
'bzr move' and 'bzr rename' allow you to rename files or directories.
42
 
'bzr remove' makes a file unversioned but keeps the working copy;
43
 
to delete that too simply delete the file.
44
 
 
45
 
'bzr log' shows a history of changes, and
46
 
'bzr info' gives summary statistical information.
47
 
'bzr check' validates all files are stored safely.
48
 
 
49
 
Files can be ignored by giving a path or a glob in .bzrignore at the
50
 
top of the tree.  Use 'bzr ignored' to see what files are ignored and
51
 
why, and 'bzr unknowns' to see files that are neither versioned or
52
 
ignored.
53
 
 
54
 
For more help on any command, type 'bzr help COMMAND', or 'bzr help
55
 
commands' for a list.
 
32
Interesting commands:
 
33
 
 
34
  bzr help [COMMAND]
 
35
      Show help screen
 
36
  bzr version
 
37
      Show software version/licence/non-warranty.
 
38
  bzr init
 
39
      Start versioning the current directory
 
40
  bzr add FILE...
 
41
      Make files versioned.
 
42
  bzr log
 
43
      Show revision history.
 
44
  bzr rename FROM TO
 
45
      Rename one file.
 
46
  bzr move FROM... DESTDIR
 
47
      Move one or more files to a different directory.
 
48
  bzr diff [FILE...]
 
49
      Show changes from last revision to working copy.
 
50
  bzr commit -m 'MESSAGE'
 
51
      Store current state as new revision.
 
52
  bzr export [-r REVNO] DESTINATION
 
53
      Export the branch state at a previous version.
 
54
  bzr status
 
55
      Show summary of pending changes.
 
56
  bzr remove FILE...
 
57
      Make a file not versioned.
 
58
  bzr info
 
59
      Show statistics about this branch.
 
60
  bzr check
 
61
      Verify history is stored safely. 
 
62
  (for more type 'bzr help commands')
56
63
"""
57
64
 
58
65
 
59
 
 
60
66
def help(topic=None):
61
67
    if topic == None:
62
68
        print global_help
66
72
        help_on_command(topic)
67
73
 
68
74
 
69
 
def command_usage(cmdname, cmdclass):
70
 
    """Return single-line grammar for command.
71
 
 
72
 
    Only describes arguments, not options.
73
 
    """
74
 
    s = cmdname + ' '
 
75
def help_on_command(cmdname):
 
76
    cmdname = str(cmdname)
 
77
 
 
78
    from inspect import getdoc
 
79
    import commands
 
80
    topic, cmdclass = commands.get_cmd_class(cmdname)
 
81
 
 
82
    doc = getdoc(cmdclass)
 
83
    if doc == None:
 
84
        raise NotImplementedError("sorry, no detailed help yet for %r" % cmdname)
 
85
 
 
86
    if '\n' in doc:
 
87
        short, rest = doc.split('\n', 1)
 
88
    else:
 
89
        short = doc
 
90
        rest = ''
 
91
 
 
92
    print 'usage: bzr ' + topic,
75
93
    for aname in cmdclass.takes_args:
76
94
        aname = aname.upper()
77
95
        if aname[-1] in ['$', '+']:
80
98
            aname = '[' + aname[:-1] + ']'
81
99
        elif aname[-1] == '*':
82
100
            aname = '[' + aname[:-1] + '...]'
83
 
        s += aname + ' '
84
 
            
85
 
    assert s[-1] == ' '
86
 
    s = s[:-1]
87
 
    
88
 
    return s
89
 
 
90
 
 
91
 
def help_on_command(cmdname):
92
 
    cmdname = str(cmdname)
93
 
 
94
 
    from inspect import getdoc
95
 
    import commands
96
 
    topic, cmdclass = commands.get_cmd_class(cmdname)
97
 
 
98
 
    doc = getdoc(cmdclass)
99
 
    if doc == None:
100
 
        raise NotImplementedError("sorry, no detailed help yet for %r" % cmdname)
101
 
 
102
 
    print 'usage:', command_usage(topic, cmdclass)
 
101
        print aname,
 
102
    print 
 
103
    print short
103
104
 
104
105
    if cmdclass.aliases:
105
106
        print 'aliases: ' + ', '.join(cmdclass.aliases)
106
107
    
107
 
    print doc
108
 
    
 
108
    if rest:
 
109
        print rest
 
110
 
109
111
    help_on_option(cmdclass.takes_options)
110
112
 
111
113
 
138
140
    for cmdname, cmdclass in accu:
139
141
        if cmdclass.hidden:
140
142
            continue
141
 
        print command_usage(cmdname, cmdclass)
 
143
        print cmdname
142
144
        help = inspect.getdoc(cmdclass)
143
145
        if help:
144
146
            print "    " + help.split('\n', 1)[0]