~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/cmd_version_info.py

  • Committer: Andrew Bennetts
  • Date: 2010-10-08 08:15:14 UTC
  • mto: This revision was merged to the branch mainline in revision 5498.
  • Revision ID: andrew.bennetts@canonical.com-20101008081514-dviqzrdfwyzsqbz2
Split NEWS into per-release doc/en/release-notes/bzr-*.txt

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2011 Canonical Ltd
 
1
# Copyright (C) 2005-2010 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
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(), """
24
22
from bzrlib import (
25
23
    branch,
26
24
    errors,
 
25
    ui,
27
26
    version_info_formats,
28
27
    workingtree,
29
28
    )
30
 
from bzrlib.i18n import gettext
31
29
""")
32
30
 
33
31
from bzrlib.commands import Command
44
42
        return version_info_formats.get_builder(format)
45
43
    except KeyError:
46
44
        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))
 
45
        raise errors.BzrCommandError('No known version info format %s.'
 
46
                                     ' Supported types are: %s'
 
47
                                     % (format, formats))
50
48
 
51
49
 
52
50
class cmd_version_info(Command):
85
83
                     Option('include-file-revisions',
86
84
                            help='Include the last revision for each file.'),
87
85
                     Option('template', type=str, help='Template for the output.'),
88
 
                     'revision',
89
86
                     ]
90
87
    takes_args = ['location?']
91
88
 
93
90
 
94
91
    def run(self, location=None, format=None,
95
92
            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'))
 
93
            include_file_revisions=False, template=None):
103
94
 
104
95
        if location is None:
105
96
            location = '.'
107
98
        if format is None:
108
99
            format = version_info_formats.format_registry.get()
109
100
 
 
101
        wt = None
110
102
        try:
111
103
            wt = workingtree.WorkingTree.open_containing(location)[0]
112
104
        except errors.NoWorkingTree:
113
105
            b = branch.Branch.open(location)
114
 
            wt = None
115
106
        else:
116
107
            b = wt.branch
117
108
 
118
 
        if all:
 
109
        if all or template:
119
110
            include_history = True
120
111
            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
 
112
            include_file_revisions=True
132
113
 
133
114
        builder = format(b, working_tree=wt,
134
115
                check_for_clean=check_clean,
135
116
                include_revision_history=include_history,
136
117
                include_file_revisions=include_file_revisions,
137
 
                template=template, revision_id=revision_id)
 
118
                template=template)
138
119
        builder.generate(self.outf)