~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/cmd_version_info.py

  • Committer: Aaron Bentley
  • Date: 2009-08-14 15:35:31 UTC
  • mto: (4603.1.22 shelve-editor)
  • mto: This revision was merged to the branch mainline in revision 4795.
  • Revision ID: aaron@aaronbentley.com-20090814153531-t3t34s2obh05uga7
Simplify unchanged case.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2011 Canonical Ltd
 
1
# Copyright (C) 2005, 2006 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
17
17
"""Commands for generating snapshot information about a bzr tree."""
18
18
 
19
19
from bzrlib.lazy_import import lazy_import
20
 
 
21
20
lazy_import(globals(), """
22
21
from bzrlib import (
23
22
    branch,
24
23
    errors,
 
24
    workingtree,
25
25
    version_info_formats,
26
 
    workingtree,
27
26
    )
28
 
from bzrlib.i18n import gettext
29
27
""")
30
 
 
31
28
from bzrlib.commands import Command
32
29
from bzrlib.option import Option, RegistryOption
33
30
 
42
39
        return version_info_formats.get_builder(format)
43
40
    except KeyError:
44
41
        formats = version_info_formats.get_builder_formats()
45
 
        raise errors.BzrCommandError(gettext('No known version info format {0}.'
46
 
                                     ' Supported types are: {1}').format(
47
 
                                     format, formats))
 
42
        raise errors.BzrCommandError('No known version info format %s.'
 
43
                                     ' Supported types are: %s'
 
44
                                     % (format, formats))
48
45
 
49
46
 
50
47
class cmd_version_info(Command):
51
 
    __doc__ = """Show version information about this tree.
 
48
    """Show version information about this tree.
52
49
 
53
50
    You can use this command to add information about version into
54
51
    source code of an application. The output can be in one of the
83
80
                     Option('include-file-revisions',
84
81
                            help='Include the last revision for each file.'),
85
82
                     Option('template', type=str, help='Template for the output.'),
86
 
                     'revision',
87
83
                     ]
88
84
    takes_args = ['location?']
89
85
 
91
87
 
92
88
    def run(self, location=None, format=None,
93
89
            all=False, check_clean=False, include_history=False,
94
 
            include_file_revisions=False, template=None,
95
 
            revision=None):
96
 
 
97
 
        if revision and len(revision) > 1:
98
 
            raise errors.BzrCommandError(
99
 
                gettext('bzr version-info --revision takes exactly'
100
 
                        ' one revision specifier'))
 
90
            include_file_revisions=False, template=None):
101
91
 
102
92
        if location is None:
103
93
            location = '.'
116
106
        if all or template:
117
107
            include_history = True
118
108
            check_clean = True
119
 
            include_file_revisions = True
120
 
 
121
 
        if revision is not None:
122
 
            revision_id = revision[0].as_revision_id(b)
123
 
        else:
124
 
            revision_id = None
 
109
            include_file_revisions=True
125
110
 
126
111
        builder = format(b, working_tree=wt,
127
112
                check_for_clean=check_clean,
128
113
                include_revision_history=include_history,
129
114
                include_file_revisions=include_file_revisions,
130
 
                template=template, revision_id=revision_id)
 
115
                template=template)
131
116
        builder.generate(self.outf)