~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/cmd_version_info.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-05-11 15:04:23 UTC
  • mfrom: (5848.1.1 2.4-cython-first)
  • Revision ID: pqm@pqm.ubuntu.com-20110511150423-tpm1ablukqalkvim
(jameinel) Default to using Cython for compiling code,
 rather than Pyrex. (John A Meinel)

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Commands for generating snapshot information about a bzr tree."""
18
18
 
19
 
from __future__ import absolute_import
20
 
 
21
19
from bzrlib.lazy_import import lazy_import
22
20
 
23
21
lazy_import(globals(), """
27
25
    version_info_formats,
28
26
    workingtree,
29
27
    )
30
 
from bzrlib.i18n import gettext
31
28
""")
32
29
 
33
30
from bzrlib.commands import Command
44
41
        return version_info_formats.get_builder(format)
45
42
    except KeyError:
46
43
        formats = version_info_formats.get_builder_formats()
47
 
        raise errors.BzrCommandError(gettext('No known version info format {0}.'
48
 
                                     ' Supported types are: {1}').format(
49
 
                                     format, formats))
 
44
        raise errors.BzrCommandError('No known version info format %s.'
 
45
                                     ' Supported types are: %s'
 
46
                                     % (format, formats))
50
47
 
51
48
 
52
49
class cmd_version_info(Command):
85
82
                     Option('include-file-revisions',
86
83
                            help='Include the last revision for each file.'),
87
84
                     Option('template', type=str, help='Template for the output.'),
88
 
                     'revision',
89
85
                     ]
90
86
    takes_args = ['location?']
91
87
 
93
89
 
94
90
    def run(self, location=None, format=None,
95
91
            all=False, check_clean=False, include_history=False,
96
 
            include_file_revisions=False, template=None,
97
 
            revision=None):
98
 
 
99
 
        if revision and len(revision) > 1:
100
 
            raise errors.BzrCommandError(
101
 
                gettext('bzr version-info --revision takes exactly'
102
 
                        ' one revision specifier'))
 
92
            include_file_revisions=False, template=None):
103
93
 
104
94
        if location is None:
105
95
            location = '.'
107
97
        if format is None:
108
98
            format = version_info_formats.format_registry.get()
109
99
 
 
100
        wt = None
110
101
        try:
111
102
            wt = workingtree.WorkingTree.open_containing(location)[0]
112
103
        except errors.NoWorkingTree:
113
104
            b = branch.Branch.open(location)
114
 
            wt = None
115
105
        else:
116
106
            b = wt.branch
117
107
 
118
 
        if all:
 
108
        if all or template:
119
109
            include_history = True
120
110
            check_clean = True
121
 
            include_file_revisions = True
122
 
        if template:
123
 
            include_history = True
124
 
            include_file_revisions = True
125
 
            if '{clean}' in template:
126
 
                check_clean = True
127
 
 
128
 
        if revision is not None:
129
 
            revision_id = revision[0].as_revision_id(b)
130
 
        else:
131
 
            revision_id = None
 
111
            include_file_revisions=True
132
112
 
133
113
        builder = format(b, working_tree=wt,
134
114
                check_for_clean=check_clean,
135
115
                include_revision_history=include_history,
136
116
                include_file_revisions=include_file_revisions,
137
 
                template=template, revision_id=revision_id)
 
117
                template=template)
138
118
        builder.generate(self.outf)