~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/cmd_version_info.py

  • Committer: John Arbash Meinel
  • Date: 2010-02-10 17:52:08 UTC
  • mfrom: (5021 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5023.
  • Revision ID: john@arbash-meinel.com-20100210175208-bubuwav4uqigu291
Merge bzr.dev 5021 to resolve NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2011 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2009 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
22
22
from bzrlib import (
23
23
    branch,
24
24
    errors,
 
25
    ui,
25
26
    version_info_formats,
26
27
    workingtree,
27
28
    )
28
 
from bzrlib.i18n import gettext
29
29
""")
30
30
 
31
31
from bzrlib.commands import Command
42
42
        return version_info_formats.get_builder(format)
43
43
    except KeyError:
44
44
        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))
 
45
        raise errors.BzrCommandError('No known version info format %s.'
 
46
                                     ' Supported types are: %s'
 
47
                                     % (format, formats))
48
48
 
49
49
 
50
50
class cmd_version_info(Command):
51
 
    __doc__ = """Show version information about this tree.
 
51
    """Show version information about this tree.
52
52
 
53
53
    You can use this command to add information about version into
54
54
    source code of an application. The output can be in one of the
83
83
                     Option('include-file-revisions',
84
84
                            help='Include the last revision for each file.'),
85
85
                     Option('template', type=str, help='Template for the output.'),
86
 
                     'revision',
87
86
                     ]
88
87
    takes_args = ['location?']
89
88
 
91
90
 
92
91
    def run(self, location=None, format=None,
93
92
            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'))
 
93
            include_file_revisions=False, template=None):
101
94
 
102
95
        if location is None:
103
96
            location = '.'
113
106
        else:
114
107
            b = wt.branch
115
108
 
116
 
        if all:
 
109
        if all or template:
117
110
            include_history = True
118
111
            check_clean = True
119
 
            include_file_revisions = True
120
 
        if template:
121
 
            include_history = True
122
 
            include_file_revisions = True
123
 
            if '{clean}' in template:
124
 
                check_clean = True
125
 
 
126
 
        if revision is not None:
127
 
            revision_id = revision[0].as_revision_id(b)
128
 
        else:
129
 
            revision_id = None
 
112
            include_file_revisions=True
130
113
 
131
114
        builder = format(b, working_tree=wt,
132
115
                check_for_clean=check_clean,
133
116
                include_revision_history=include_history,
134
117
                include_file_revisions=include_file_revisions,
135
 
                template=template, revision_id=revision_id)
136
 
        builder.generate(self.outf)
 
118
                template=template)
 
119
        builder.generate(ui.ui_factory.make_output_stream())