~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-10-09 13:52:06 UTC
  • mfrom: (6202.1.3 revno-revision)
  • Revision ID: pqm@pqm.ubuntu.com-20111009135206-t3utsln6mtzv9eut
(jelmer) Add a --revision argument to 'bzr revno'. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
    version_info_formats,
26
26
    workingtree,
27
27
    )
 
28
from bzrlib.i18n import gettext
28
29
""")
29
30
 
30
31
from bzrlib.commands import Command
41
42
        return version_info_formats.get_builder(format)
42
43
    except KeyError:
43
44
        formats = version_info_formats.get_builder_formats()
44
 
        raise errors.BzrCommandError('No known version info format %s.'
45
 
                                     ' Supported types are: %s'
46
 
                                     % (format, formats))
 
45
        raise errors.BzrCommandError(gettext('No known version info format {0}.'
 
46
                                     ' Supported types are: {1}').format(
 
47
                                     format, formats))
47
48
 
48
49
 
49
50
class cmd_version_info(Command):
82
83
                     Option('include-file-revisions',
83
84
                            help='Include the last revision for each file.'),
84
85
                     Option('template', type=str, help='Template for the output.'),
 
86
                     'revision',
85
87
                     ]
86
88
    takes_args = ['location?']
87
89
 
89
91
 
90
92
    def run(self, location=None, format=None,
91
93
            all=False, check_clean=False, include_history=False,
92
 
            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'))
93
101
 
94
102
        if location is None:
95
103
            location = '.'
108
116
        if all or template:
109
117
            include_history = True
110
118
            check_clean = True
111
 
            include_file_revisions=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
112
125
 
113
126
        builder = format(b, working_tree=wt,
114
127
                check_for_clean=check_clean,
115
128
                include_revision_history=include_history,
116
129
                include_file_revisions=include_file_revisions,
117
 
                template=template)
 
130
                template=template, revision_id=revision_id)
118
131
        builder.generate(self.outf)