~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bundle/commands.py

  • Committer: John Arbash Meinel
  • Author(s): Mark Hammond
  • Date: 2008-09-09 17:02:21 UTC
  • mto: This revision was merged to the branch mainline in revision 3697.
  • Revision ID: john@arbash-meinel.com-20080909170221-svim3jw2mrz0amp3
An updated transparent icon for bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2011 Canonical Ltd
 
1
# Copyright (C) 2006 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
12
12
#
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
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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
25
 
 
 
23
import sys
26
24
from cStringIO import StringIO
27
25
 
28
26
from bzrlib.lazy_import import lazy_import
35
33
    urlutils,
36
34
    transport,
37
35
    )
38
 
from bzrlib.i18n import gettext
39
36
""")
40
37
 
41
38
from bzrlib.commands import Command
 
39
from bzrlib.option import Option
 
40
from bzrlib.trace import note
42
41
 
43
42
 
44
43
class cmd_bundle_info(Command):
45
 
    __doc__ = """Output interesting stats about a bundle"""
 
44
    """Output interesting stats about a bundle"""
46
45
 
47
46
    hidden = True
48
47
    takes_args = ['location']
55
54
        from bzrlib import osutils
56
55
        term_encoding = osutils.get_terminal_encoding()
57
56
        bundle_info = read_mergeable_from_url(location)
58
 
        if isinstance(bundle_info, merge_directive.BaseMergeDirective):
 
57
        if isinstance(bundle_info, merge_directive._BaseMergeDirective):
59
58
            bundle_file = StringIO(bundle_info.get_raw_bundle())
60
59
            bundle_info = read_bundle(bundle_file)
61
60
        else:
62
61
            if verbose:
63
 
                raise errors.BzrCommandError(gettext(
64
 
                            '--verbose requires a merge directive'))
 
62
                raise errors.BzrCommandError('--verbose requires a merge'
 
63
                    ' directive')
65
64
        reader_method = getattr(bundle_info, 'get_bundle_reader', None)
66
65
        if reader_method is None:
67
 
            raise errors.BzrCommandError(gettext('Bundle format not supported'))
 
66
            raise errors.BzrCommandError('Bundle format not supported')
68
67
 
69
68
        by_kind = {}
70
69
        file_ids = set()
74
73
                (bytes, parents, repo_kind, revision_id, file_id))
75
74
            if file_id is not None:
76
75
                file_ids.add(file_id)
77
 
        self.outf.write(gettext('Records\n'))
 
76
        self.outf.write('Records\n')
78
77
        for kind, records in sorted(by_kind.iteritems()):
79
78
            multiparent = sum(1 for b, m, k, r, f in records if
80
79
                              len(m.get('parents', [])) > 1)
81
 
            self.outf.write(gettext('{0}: {1} ({2} multiparent)\n').format(
82
 
                kind, len(records), multiparent))
83
 
        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))
84
83
        self.outf.write('\n')
85
84
        nicks = set()
86
85
        committers = set()
89
88
                nicks.add(revision.properties['branch-nick'])
90
89
            committers.add(revision.committer)
91
90
 
92
 
        self.outf.write(gettext('Revisions\n'))
93
 
        self.outf.write((gettext('nicks: %s\n')
 
91
        self.outf.write('Revisions\n')
 
92
        self.outf.write(('nicks: %s\n'
94
93
            % ', '.join(sorted(nicks))).encode(term_encoding, 'replace'))
95
 
        self.outf.write((gettext('committers: \n%s\n') %
 
94
        self.outf.write(('committers: \n%s\n' %
96
95
        '\n'.join(sorted(committers)).encode(term_encoding, 'replace')))
97
96
        if verbose:
98
97
            self.outf.write('\n')
100
99
            line = bundle_file.readline()
101
100
            line = bundle_file.readline()
102
101
            content = bundle_file.read().decode('bz2')
103
 
            self.outf.write(gettext("Decoded contents\n"))
 
102
            self.outf.write("Decoded contents\n")
104
103
            self.outf.write(content)
105
104
            self.outf.write('\n')