~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bundle/commands.py

  • Committer: Ian Clatworthy
  • Date: 2007-08-13 14:33:10 UTC
  • mto: (2733.1.1 ianc-integration)
  • mto: This revision was merged to the branch mainline in revision 2734.
  • Revision ID: ian.clatworthy@internode.on.net-20070813143310-twhj4la0qnupvze8
Added Quick Start Summary

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 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
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
"""\
17
17
This is an attempt to take the internal delta object, and represent
18
18
it as a single-file text-only changeset.
41
41
 
42
42
 
43
43
class cmd_bundle_info(Command):
44
 
    __doc__ = """Output interesting stats about a bundle"""
 
44
    """Output interesting stats about a bundle"""
45
45
 
46
46
    hidden = True
47
47
    takes_args = ['location']
48
 
    takes_options = ['verbose']
 
48
    takes_options = []
49
49
    encoding_type = 'exact'
50
50
 
51
51
    def run(self, location, verbose=False):
54
54
        from bzrlib import osutils
55
55
        term_encoding = osutils.get_terminal_encoding()
56
56
        bundle_info = read_mergeable_from_url(location)
57
 
        if isinstance(bundle_info, merge_directive.BaseMergeDirective):
58
 
            bundle_file = StringIO(bundle_info.get_raw_bundle())
59
 
            bundle_info = read_bundle(bundle_file)
60
 
        else:
61
 
            if verbose:
62
 
                raise errors.BzrCommandError('--verbose requires a merge'
63
 
                    ' directive')
 
57
        if isinstance(bundle_info, merge_directive._BaseMergeDirective):
 
58
            bundle_info = read_bundle(StringIO(bundle_info.get_raw_bundle()))
64
59
        reader_method = getattr(bundle_info, 'get_bundle_reader', None)
65
60
        if reader_method is None:
66
61
            raise errors.BzrCommandError('Bundle format not supported')
73
68
                (bytes, parents, repo_kind, revision_id, file_id))
74
69
            if file_id is not None:
75
70
                file_ids.add(file_id)
76
 
        self.outf.write('Records\n')
 
71
        print >> self.outf, 'Records'
77
72
        for kind, records in sorted(by_kind.iteritems()):
78
 
            multiparent = sum(1 for b, m, k, r, f in records if
79
 
                              len(m.get('parents', [])) > 1)
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))
83
 
        self.outf.write('\n')
 
73
            multiparent = sum(1 for b, p, k, r, f in records if len(p) > 1)
 
74
            print >> self.outf, '%s: %d (%d multiparent)' % \
 
75
                (kind, len(records), multiparent)
 
76
        print >> self.outf, 'unique files: %d' % len(file_ids)
 
77
        print >> self.outf
84
78
        nicks = set()
85
79
        committers = set()
86
80
        for revision in bundle_info.real_revisions:
88
82
                nicks.add(revision.properties['branch-nick'])
89
83
            committers.add(revision.committer)
90
84
 
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')))
 
85
        print >> self.outf, 'Revisions'
 
86
        print >> self.outf, ('nicks: %s'
 
87
            % ', '.join(sorted(nicks))).encode(term_encoding, 'replace')
 
88
        print >> self.outf, ('committers: \n%s' %
 
89
        '\n'.join(sorted(committers)).encode(term_encoding, 'replace'))
96
90
        if verbose:
97
 
            self.outf.write('\n')
 
91
            print >> self.outf
98
92
            bundle_file.seek(0)
99
93
            line = bundle_file.readline()
100
94
            line = bundle_file.readline()
101
95
            content = bundle_file.read().decode('bz2')
102
 
            self.outf.write("Decoded contents\n")
 
96
            print >> self.outf, "Decoded contents"
103
97
            self.outf.write(content)
104
 
            self.outf.write('\n')
 
98
            print >> self.outf