/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/bundle/commands.py

  • Committer: Robert Collins
  • Date: 2010-05-06 11:08:10 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506110810-h3j07fh5gmw54s25
Cleaner matcher matching revised unlocking protocol.

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
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
16
"""\
18
17
This is an attempt to take the internal delta object, and represent
19
18
it as a single-file text-only changeset.
21
20
and for applying a changeset.
22
21
"""
23
22
 
24
 
from __future__ import absolute_import
 
23
import sys
 
24
from cStringIO import StringIO
25
25
 
26
 
from ..lazy_import import lazy_import
 
26
from bzrlib.lazy_import import lazy_import
27
27
lazy_import(globals(), """
28
 
from breezy import (
 
28
from bzrlib import (
29
29
    branch,
30
30
    errors,
31
31
    merge_directive,
33
33
    urlutils,
34
34
    transport,
35
35
    )
36
 
from breezy.i18n import gettext
37
36
""")
38
37
 
39
 
from ..commands import Command
40
 
from ..sixish import (
41
 
    BytesIO,
42
 
    viewitems,
43
 
    )
 
38
from bzrlib.commands import Command
 
39
from bzrlib.option import Option
 
40
from bzrlib.trace import note
44
41
 
45
42
 
46
43
class cmd_bundle_info(Command):
52
49
    encoding_type = 'exact'
53
50
 
54
51
    def run(self, location, verbose=False):
55
 
        from breezy.bundle.serializer import read_bundle
56
 
        from breezy.bundle import read_mergeable_from_url
57
 
        from breezy import osutils
 
52
        from bzrlib.bundle.serializer import read_bundle
 
53
        from bzrlib.bundle import read_mergeable_from_url
 
54
        from bzrlib import osutils
58
55
        term_encoding = osutils.get_terminal_encoding()
59
56
        bundle_info = read_mergeable_from_url(location)
60
57
        if isinstance(bundle_info, merge_directive.BaseMergeDirective):
61
 
            bundle_file = BytesIO(bundle_info.get_raw_bundle())
 
58
            bundle_file = StringIO(bundle_info.get_raw_bundle())
62
59
            bundle_info = read_bundle(bundle_file)
63
60
        else:
64
61
            if verbose:
65
 
                raise errors.BzrCommandError(gettext(
66
 
                    '--verbose requires a merge directive'))
 
62
                raise errors.BzrCommandError('--verbose requires a merge'
 
63
                    ' directive')
67
64
        reader_method = getattr(bundle_info, 'get_bundle_reader', None)
68
65
        if reader_method is None:
69
 
            raise errors.BzrCommandError(
70
 
                gettext('Bundle format not supported'))
 
66
            raise errors.BzrCommandError('Bundle format not supported')
71
67
 
72
68
        by_kind = {}
73
69
        file_ids = set()
74
70
        for bytes, parents, repo_kind, revision_id, file_id\
75
 
                in reader_method().iter_records():
 
71
            in reader_method().iter_records():
76
72
            by_kind.setdefault(repo_kind, []).append(
77
73
                (bytes, parents, repo_kind, revision_id, file_id))
78
74
            if file_id is not None:
79
75
                file_ids.add(file_id)
80
 
        self.outf.write(gettext('Records\n'))
81
 
        for kind, records in sorted(viewitems(by_kind)):
 
76
        self.outf.write('Records\n')
 
77
        for kind, records in sorted(by_kind.iteritems()):
82
78
            multiparent = sum(1 for b, m, k, r, f in records if
83
79
                              len(m.get('parents', [])) > 1)
84
 
            self.outf.write(gettext('{0}: {1} ({2} multiparent)\n').format(
85
 
                kind, len(records), multiparent))
86
 
        self.outf.write(gettext('unique files: %d\n') % len(file_ids))
 
80
            self.outf.write('%s: %d (%d multiparent)\n' % \
 
81
                (kind, len(records), multiparent))
 
82
        self.outf.write('unique files: %d\n' % len(file_ids))
87
83
        self.outf.write('\n')
88
84
        nicks = set()
89
85
        committers = set()
92
88
                nicks.add(revision.properties['branch-nick'])
93
89
            committers.add(revision.committer)
94
90
 
95
 
        self.outf.write(gettext('Revisions\n'))
96
 
        self.outf.write((gettext('nicks: %s\n')
97
 
                         % ', '.join(sorted(nicks))).encode(term_encoding, 'replace'))
98
 
        self.outf.write((gettext('committers: \n%s\n') %
99
 
                         '\n'.join(sorted(committers)).encode(term_encoding, 'replace')))
 
91
        self.outf.write('Revisions\n')
 
92
        self.outf.write(('nicks: %s\n'
 
93
            % ', '.join(sorted(nicks))).encode(term_encoding, 'replace'))
 
94
        self.outf.write(('committers: \n%s\n' %
 
95
        '\n'.join(sorted(committers)).encode(term_encoding, 'replace')))
100
96
        if verbose:
101
97
            self.outf.write('\n')
102
98
            bundle_file.seek(0)
103
99
            line = bundle_file.readline()
104
100
            line = bundle_file.readline()
105
 
            import bz2
106
 
            content = bz2.decompress(bundle_file.read())
107
 
            self.outf.write(gettext("Decoded contents\n"))
 
101
            content = bundle_file.read().decode('bz2')
 
102
            self.outf.write("Decoded contents\n")
108
103
            self.outf.write(content)
109
104
            self.outf.write('\n')