/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,
57
            all=False, check_clean=False, include_history=False):
58
59
        if location is None:
60
            location = u'.'
61
62
        if format is None:
63
            format = version_formats[None]
64
65
        # TODO: jam 20051228 This could be open_containing
66
        b = Branch.open(location)
67
68
        outf = codecs.getwriter('utf-8')(sys.stdout)
69
70
        include_log_info = False
71
        include_log_deltas = False
72
        if all:
73
            include_history = True
74
            check_clean = True
75
            include_log_info = True
76
            include_log_deltas = True
77
78
        format(b, to_file=outf,
79
                check_for_clean=check_clean,
80
                include_revision_history=include_history,
81
                include_log_info=include_log_info,
82
                include_log_deltas=include_log_deltas)
83
84
85
register_command(cmd_version_info)
86
87
0.8.1 by John Arbash Meinel
Creating a plugin to ease generating version information from a tree.
88
def test_suite():
89
    from bzrlib.tests.TestUtil import TestLoader, TestSuite
90
    import test_version_info
91
    import test_bb_version_info
92
93
    suite = TestSuite()
94
    loader = TestLoader()
95
    suite.addTest(loader.loadTestsFromModule(test_version_info))
96
    suite.addTest(loader.loadTestsFromModule(test_bb_version_info))
97
98
    return suite