17
17
"""Commands for generating snapshot information about a bzr tree."""
19
from bzrlib.lazy_import import lazy_import
20
lazy_import(globals(), """
21
22
from bzrlib import (
24
23
version_info_formats,
25
from bzrlib.branch import Branch
28
26
from bzrlib.commands import Command
27
from bzrlib.errors import BzrCommandError
29
28
from bzrlib.option import Option
29
from bzrlib.workingtree import WorkingTree
32
33
def _parse_version_info_format(format):
33
"""Convert a string passed by the user into a VersionInfoFormat.
35
This looks in the version info format registry, and if the format
36
cannot be found, generates a useful error exception.
39
35
return version_info_formats.get_builder(format)
41
37
formats = version_info_formats.get_builder_formats()
42
raise errors.BzrCommandError('No known version info format %s.'
43
' Supported types are: %s'
38
raise BzrCommandError('No known version info format %s.'
39
' Supported types are: %s'
47
43
class cmd_version_info(Command):
48
"""Show version information about this tree."""
44
"""Generate version information about this tree."""
50
46
takes_options = [Option('format', type=_parse_version_info_format,
51
47
help='Select the output format'),
65
61
include_file_revisions=False):
67
63
if location is None:
71
67
format = version_info_formats.get_builder(None)
75
wt = workingtree.WorkingTree.open_containing(location)[0]
76
except errors.NoWorkingTree:
77
b = branch.Branch.open(location)
71
wt = WorkingTree.open_containing(location)[0]
73
b = Branch.open(location)