/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
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
# Copyright (C) 2006 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

"""A collection of extra help information for using bzr.

Help topics are meant to be help for items that aren't commands, but will
help bzr become fully learnable without referring to a tutorial.
"""

import sys


_HELP_TOPICS={}


def add_topic(name, obj, comment):
    """add a new topic, obj can be a function or a text; comment is a text"""
    _HELP_TOPICS[name]=(obj, comment)


def write_topic(name, outfile=sys.stdout):
    """write to outfile the topic named "name"""
    obj, comment = _HELP_TOPICS[name]
    if callable(obj):
        obj(name, outfile)
    else:
        outfile.write(obj)


def is_topic(name):
    """is "name" a topic ?"""
    return name in _HELP_TOPICS


def get_topics_list( ):
    """return a dict like {topic_name:topi_comment}"""
    return _HELP_TOPICS


#----------------------------------------------------

def _help_on_topics(name, outfile):
    """Write out the help for topics to outfile"""

    topics = get_topics_list()
    lmax = max(len(topic) for topic in topics)
        
    for topic in topics:
        obj, comment = topics[topic]
        spaces = " " * (lmax-len(topic))
        outfile.write("%s%s %s\n" % (topic, spaces, comment))


def _help_on_revisionspec(name, outfile):
    """Write out the help for revison spec information"""
    import bzrlib.revisionspec

    outfile.write("\nRevision prefix specifier:"
                  "\n--------------------------\n")

    for i in bzrlib.revisionspec.SPEC_TYPES:
        doc = i.__doc__
        if doc == bzrlib.revisionspec.RevisionSpec.__doc__:
            doc = "N/A\n"
        while (doc[-2:] == '\n\n' or doc[-1:] == ' '):
            doc = doc[:-1]

        outfile.write("  %s %s\n\n" % (i.prefix, doc))


_basic_help= \
"""Bazaar -- a free distributed version-control tool
http://bazaar-vcs.org/

Basic commands:

  bzr init           makes this directory a versioned branch
  bzr branch         make a copy of another branch

  bzr add            make files or directories versioned
  bzr ignore         ignore a file or pattern
  bzr mv             move or rename a versioned file

  bzr status         summarize changes in working copy
  bzr diff           show detailed diffs

  bzr merge          pull in changes from another branch
  bzr commit         save some or all changes

  bzr log            show history of changes
  bzr check          validate storage

  bzr help init      more help on e.g. init command
  bzr help commands  list all commands
  bzr help topics    list all help topics
"""


add_topic("revisionspec", _help_on_revisionspec, "Revisions specifier")
add_topic("basic", _basic_help, "Basic commands")
add_topic("topics", _help_on_topics, "Topics list")