/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: 2007-10-05 02:41:37 UTC
  • mto: (2592.3.166 repository)
  • mto: This revision was merged to the branch mainline in revision 2896.
  • Revision ID: robertc@robertcollins.net-20071005024137-kn7brcu07nu8cwl1
* The class ``bzrlib.repofmt.knitrepo.KnitRepository3`` has been folded into
  ``KnitRepository`` by parameters to the constructor. (Robert Collins)
* ``bzrlib.xml_serializer.Serializer`` is now responsible for checking that
  mandatory attributes are present on serialisation and deserialisation.
  This fixes some holes in API usage and allows better separation between
  physical storage and object serialisation. (Robert Collins)

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']
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):
 
57
        if isinstance(bundle_info, merge_directive._BaseMergeDirective):
58
58
            bundle_file = StringIO(bundle_info.get_raw_bundle())
59
59
            bundle_info = read_bundle(bundle_file)
60
60
        else:
61
61
            if verbose:
62
 
                raise errors.BzrCommandError('--verbose requires a merge'
63
 
                    ' directive')
 
62
                raise errors.BzrCommandError('Verbose requires a merge'
 
63
                                             ' directive')
64
64
        reader_method = getattr(bundle_info, 'get_bundle_reader', None)
65
65
        if reader_method is None:
66
66
            raise errors.BzrCommandError('Bundle format not supported')
73
73
                (bytes, parents, repo_kind, revision_id, file_id))
74
74
            if file_id is not None:
75
75
                file_ids.add(file_id)
76
 
        self.outf.write('Records\n')
 
76
        print >> self.outf, 'Records'
77
77
        for kind, records in sorted(by_kind.iteritems()):
78
78
            multiparent = sum(1 for b, m, k, r, f in records if
79
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')
 
80
            print >> self.outf, '%s: %d (%d multiparent)' % \
 
81
                (kind, len(records), multiparent)
 
82
        print >> self.outf, 'unique files: %d' % len(file_ids)
 
83
        print >> self.outf
84
84
        nicks = set()
85
85
        committers = set()
86
86
        for revision in bundle_info.real_revisions:
88
88
                nicks.add(revision.properties['branch-nick'])
89
89
            committers.add(revision.committer)
90
90
 
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')))
 
91
        print >> self.outf, 'Revisions'
 
92
        print >> self.outf, ('nicks: %s'
 
93
            % ', '.join(sorted(nicks))).encode(term_encoding, 'replace')
 
94
        print >> self.outf, ('committers: \n%s' %
 
95
        '\n'.join(sorted(committers)).encode(term_encoding, 'replace'))
96
96
        if verbose:
97
 
            self.outf.write('\n')
 
97
            print >> self.outf
98
98
            bundle_file.seek(0)
99
99
            line = bundle_file.readline()
100
100
            line = bundle_file.readline()
101
101
            content = bundle_file.read().decode('bz2')
102
 
            self.outf.write("Decoded contents\n")
 
102
            print >> self.outf, "Decoded contents"
103
103
            self.outf.write(content)
104
 
            self.outf.write('\n')
 
104
            print >> self.outf