/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.8.1 by John Arbash Meinel
Creating a plugin to ease generating version information from a tree.
1
# Copyright (C) 2005 Canonical Ltd
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
"""\
18
Plugin for generating snapshot information about a bzr tree.
19
"""
20
0.8.2 by John Arbash Meinel
Have working rio output
21
import sys
22
import codecs
23
24
from bzrlib.branch import Branch
25
from bzrlib.commands import Command, register_command
26
from bzrlib.errors import BzrCommandError
27
from bzrlib.option import Option
28
29
from generate_version_info import version_formats
30
31
32
def _parse_version_info_format(format):
33
    try:
34
        return version_formats[format]
35
    except KeyError:
36
        formats = version_formats.keys()
37
        formats.remove(None)
38
        raise BzrCommandError('No known version info format %s.'
39
                ' Supported types are: %s' 
40
                % (format, formats))
41
42
43
class cmd_version_info(Command):
44
    """Generate version information about this tree.
45
    """
46
47
    takes_options = [Option('format', type=_parse_version_info_format,
48
                            help='Select the '),
49
                     Option('all', help='include all possible information'),
50
                     Option('check-clean', help='check if tree is clean'),
51
                     Option('include-history', 
52
                             help='Include the revision-history')
53
                     ]
54
    takes_args = ['location?']
55
56
    def run(self, location=None, format=None,
0.8.3 by John Arbash Meinel
Playing around with some formats
57
            all=False, check_clean=False, include_history=False,
58
            verbose=False):
0.8.2 by John Arbash Meinel
Have working rio output
59
60
        if location is None:
61
            location = u'.'
62
63
        if format is None:
64
            format = version_formats[None]
65
66
        # TODO: jam 20051228 This could be open_containing
67
        b = Branch.open(location)
68
69
        outf = codecs.getwriter('utf-8')(sys.stdout)
70
71
        if all:
72
            include_history = True
73
            check_clean = True
74
75
        format(b, to_file=outf,
76
                check_for_clean=check_clean,
0.8.4 by John Arbash Meinel
Cleaned up formats include-history always displays the log message.
77
                include_revision_history=include_history)
0.8.2 by John Arbash Meinel
Have working rio output
78
79
80
register_command(cmd_version_info)
81
82
0.8.1 by John Arbash Meinel
Creating a plugin to ease generating version information from a tree.
83
def test_suite():
84
    from bzrlib.tests.TestUtil import TestLoader, TestSuite
85
    import test_version_info
86
    import test_bb_version_info
87
88
    suite = TestSuite()
89
    loader = TestLoader()
90
    suite.addTest(loader.loadTestsFromModule(test_version_info))
91
    suite.addTest(loader.loadTestsFromModule(test_bb_version_info))
92
93
    return suite