/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,
0.8.11 by John Arbash Meinel
Comment fix
48
                            help='Select the output format'),
0.8.2 by John Arbash Meinel
Have working rio output
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
0.8.10 by John Arbash Meinel
Forgot the api change.
66
        b = Branch.open_containing(location)[0]
0.8.2 by John Arbash Meinel
Have working rio output
67
68
        outf = codecs.getwriter('utf-8')(sys.stdout)
69
70
        if all:
71
            include_history = True
72
            check_clean = True
73
74
        format(b, to_file=outf,
75
                check_for_clean=check_clean,
0.8.4 by John Arbash Meinel
Cleaned up formats include-history always displays the log message.
76
                include_revision_history=include_history)
0.8.2 by John Arbash Meinel
Have working rio output
77
78
79
register_command(cmd_version_info)
80
81
0.8.1 by John Arbash Meinel
Creating a plugin to ease generating version information from a tree.
82
def test_suite():
83
    from bzrlib.tests.TestUtil import TestLoader, TestSuite
84
    import test_version_info
85
    import test_bb_version_info
86
87
    suite = TestSuite()
88
    loader = TestLoader()
89
    suite.addTest(loader.loadTestsFromModule(test_version_info))
90
    suite.addTest(loader.loadTestsFromModule(test_bb_version_info))
91
92
    return suite