/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', 
0.8.13 by John Arbash Meinel
Including file-revisions fields, updated test suite.
52
                            help='Include the revision-history'),
53
                     Option('include-file-revisions',
54
                            help='Include the last revision for each file')
0.8.2 by John Arbash Meinel
Have working rio output
55
                     ]
56
    takes_args = ['location?']
57
58
    def run(self, location=None, format=None,
0.8.3 by John Arbash Meinel
Playing around with some formats
59
            all=False, check_clean=False, include_history=False,
0.8.13 by John Arbash Meinel
Including file-revisions fields, updated test suite.
60
            include_file_revisions=False):
0.8.2 by John Arbash Meinel
Have working rio output
61
62
        if location is None:
63
            location = u'.'
64
65
        if format is None:
66
            format = version_formats[None]
67
0.8.10 by John Arbash Meinel
Forgot the api change.
68
        b = Branch.open_containing(location)[0]
0.8.2 by John Arbash Meinel
Have working rio output
69
70
        outf = codecs.getwriter('utf-8')(sys.stdout)
71
72
        if all:
73
            include_history = True
74
            check_clean = True
0.8.13 by John Arbash Meinel
Including file-revisions fields, updated test suite.
75
            include_file_revisions=True
0.8.2 by John Arbash Meinel
Have working rio output
76
77
        format(b, to_file=outf,
78
                check_for_clean=check_clean,
0.8.13 by John Arbash Meinel
Including file-revisions fields, updated test suite.
79
                include_revision_history=include_history,
80
                include_file_revisions=include_file_revisions)
0.8.2 by John Arbash Meinel
Have working rio output
81
82
83
register_command(cmd_version_info)
84
85
0.8.1 by John Arbash Meinel
Creating a plugin to ease generating version information from a tree.
86
def test_suite():
87
    from bzrlib.tests.TestUtil import TestLoader, TestSuite
88
    import test_version_info
89
    import test_bb_version_info
90
91
    suite = TestSuite()
92
    loader = TestLoader()
93
    suite.addTest(loader.loadTestsFromModule(test_version_info))
94
    suite.addTest(loader.loadTestsFromModule(test_bb_version_info))
95
96
    return suite