~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/cmd_version_info.py

  • Committer: Patch Queue Manager
  • Date: 2011-12-18 21:24:45 UTC
  • mfrom: (6379.1.1 no-termios)
  • Revision ID: pqm@pqm.ubuntu.com-20111218212445-onsppr7rdov3cw42
(jelmer) Avoid always importing termios and tty in bzrlib.osutils. (Jelmer
 Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005-2011 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,
26
25
    version_info_formats,
27
26
    workingtree,
28
27
    )
 
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('No known version info format %s.'
46
 
                                     ' Supported types are: %s'
47
 
                                     % (format, formats))
 
45
        raise errors.BzrCommandError(gettext('No known version info format {0}.'
 
46
                                     ' Supported types are: {1}').format(
 
47
                                     format, formats))
48
48
 
49
49
 
50
50
class cmd_version_info(Command):
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',
86
87
                     ]
87
88
    takes_args = ['location?']
88
89
 
90
91
 
91
92
    def run(self, location=None, format=None,
92
93
            all=False, check_clean=False, include_history=False,
93
 
            include_file_revisions=False, template=None):
 
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'))
94
101
 
95
102
        if location is None:
96
103
            location = '.'
106
113
        else:
107
114
            b = wt.branch
108
115
 
109
 
        if all or template:
 
116
        if all:
110
117
            include_history = True
111
118
            check_clean = True
112
 
            include_file_revisions=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
113
130
 
114
131
        builder = format(b, working_tree=wt,
115
132
                check_for_clean=check_clean,
116
133
                include_revision_history=include_history,
117
134
                include_file_revisions=include_file_revisions,
118
 
                template=template)
119
 
        builder.generate(ui.ui_factory.make_output_stream())
 
135
                template=template, revision_id=revision_id)
 
136
        builder.generate(self.outf)