/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/version_info.py

  • Committer: John Arbash Meinel
  • Date: 2006-09-20 14:51:03 UTC
  • mfrom: (0.8.23 version_info)
  • mto: This revision was merged to the branch mainline in revision 2028.
  • Revision ID: john@arbash-meinel.com-20060920145103-02725c6d6c886040
[merge] version-info plugin, and cleanup for layout in bzr

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 bzrlib.lazy_import import lazy_import
20
 
lazy_import(globals(), """
 
19
import sys
 
20
import codecs
 
21
 
21
22
from bzrlib import (
22
 
    branch,
23
 
    errors,
24
23
    version_info_formats,
25
 
    workingtree,
26
24
    )
27
 
""")
 
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
 
30
 
30
31
 
31
32
 
32
33
def _parse_version_info_format(format):
33
 
    """Convert a string passed by the user into a VersionInfoFormat.
34
 
 
35
 
    This looks in the version info format registry, and if the format
36
 
    cannot be found, generates a useful error exception.
37
 
    """
38
34
    try:
39
35
        return version_info_formats.get_builder(format)
40
36
    except KeyError:
41
37
        formats = version_info_formats.get_builder_formats()
42
 
        raise errors.BzrCommandError('No known version info format %s.'
43
 
                                     ' Supported types are: %s'
44
 
                                     % (format, formats))
 
38
        raise BzrCommandError('No known version info format %s.'
 
39
                              ' Supported types are: %s'
 
40
                              % (format, formats))
45
41
 
46
42
 
47
43
class cmd_version_info(Command):
48
 
    """Show version information about this tree."""
 
44
    """Generate version information about this tree."""
49
45
 
50
46
    takes_options = [Option('format', type=_parse_version_info_format,
51
47
                            help='Select the output format'),
65
61
            include_file_revisions=False):
66
62
 
67
63
        if location is None:
68
 
            location = '.'
 
64
            location = u'.'
69
65
 
70
66
        if format is None:
71
67
            format = version_info_formats.get_builder(None)
72
68
 
73
69
        wt = None
74
70
        try:
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]
 
72
        except NoWorkingTree:
 
73
            b = Branch.open(location)
78
74
        else:
79
75
            b = wt.branch
80
76