/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to brzlib/cmd_version_info.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-21 12:41:27 UTC
  • mto: This revision was merged to the branch mainline in revision 6623.
  • Revision ID: jelmer@jelmer.uk-20170521124127-iv8etg0vwymyai6y
s/bzr/brz/ in apport config.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
"""Commands for generating snapshot information about a brz tree."""
18
 
 
19
 
from .lazy_import import lazy_import
 
17
"""Commands for generating snapshot information about a bzr tree."""
 
18
 
 
19
from __future__ import absolute_import
 
20
 
 
21
from brzlib.lazy_import import lazy_import
20
22
 
21
23
lazy_import(globals(), """
22
 
from breezy import (
 
24
from brzlib import (
23
25
    branch,
 
26
    errors,
24
27
    version_info_formats,
25
28
    workingtree,
26
29
    )
27
 
from breezy.i18n import gettext
 
30
from brzlib.i18n import gettext
28
31
""")
29
32
 
30
 
from . import (
31
 
    errors,
32
 
    )
33
 
from .commands import Command
34
 
from .option import Option, RegistryOption
 
33
from brzlib.commands import Command
 
34
from brzlib.option import Option, RegistryOption
35
35
 
36
36
 
37
37
def _parse_version_info_format(format):
44
44
        return version_info_formats.get_builder(format)
45
45
    except KeyError:
46
46
        formats = version_info_formats.get_builder_formats()
47
 
        raise errors.BzrCommandError(
48
 
            gettext('No known version info format {0}.'
49
 
                    ' Supported types are: {1}').format(format, formats))
 
47
        raise errors.BzrCommandError(gettext('No known version info format {0}.'
 
48
                                     ' Supported types are: {1}').format(
 
49
                                     format, formats))
50
50
 
51
51
 
52
52
class cmd_version_info(Command):
58
58
 
59
59
    For example::
60
60
 
61
 
      brz version-info --custom \\
 
61
      bzr version-info --custom \\
62
62
        --template="#define VERSION_INFO \\"Project 1.2.3 (r{revno})\\"\\n"
63
63
 
64
64
    will produce a C header file with formatted string containing the
74
74
    """
75
75
 
76
76
    takes_options = [RegistryOption('format',
77
 
                                    'Select the output format.',
78
 
                                    value_switches=True,
79
 
                                    lazy_registry=('breezy.version_info_formats',
80
 
                                                   'format_registry')),
 
77
                            'Select the output format.',
 
78
                            value_switches=True,
 
79
                            lazy_registry=('brzlib.version_info_formats',
 
80
                                           'format_registry')),
81
81
                     Option('all', help='Include all possible information.'),
82
82
                     Option('check-clean', help='Check if tree is clean.'),
83
83
                     Option('include-history',
84
84
                            help='Include the revision-history.'),
85
85
                     Option('include-file-revisions',
86
86
                            help='Include the last revision for each file.'),
87
 
                     Option('template', type=str,
88
 
                            help='Template for the output.'),
 
87
                     Option('template', type=str, help='Template for the output.'),
89
88
                     'revision',
90
89
                     ]
91
90
    takes_args = ['location?']
92
91
 
93
 
    encoding_type = 'replace'
 
92
    encoding_type = 'exact'
94
93
 
95
94
    def run(self, location=None, format=None,
96
95
            all=False, check_clean=False, include_history=False,
99
98
 
100
99
        if revision and len(revision) > 1:
101
100
            raise errors.BzrCommandError(
102
 
                gettext('brz version-info --revision takes exactly'
 
101
                gettext('bzr version-info --revision takes exactly'
103
102
                        ' one revision specifier'))
104
103
 
105
104
        if location is None:
132
131
            revision_id = None
133
132
 
134
133
        builder = format(b, working_tree=wt,
135
 
                         check_for_clean=check_clean,
136
 
                         include_revision_history=include_history,
137
 
                         include_file_revisions=include_file_revisions,
138
 
                         template=template, revision_id=revision_id)
 
134
                check_for_clean=check_clean,
 
135
                include_revision_history=include_history,
 
136
                include_file_revisions=include_file_revisions,
 
137
                template=template, revision_id=revision_id)
139
138
        builder.generate(self.outf)