/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

merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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.
45
45
 
46
46
    hidden = True
47
47
    takes_args = ['location']
48
 
    takes_options = []
 
48
    takes_options = ['verbose']
49
49
    encoding_type = 'exact'
50
50
 
51
51
    def run(self, location, verbose=False):
55
55
        term_encoding = osutils.get_terminal_encoding()
56
56
        bundle_info = read_mergeable_from_url(location)
57
57
        if isinstance(bundle_info, merge_directive._BaseMergeDirective):
58
 
            bundle_info = read_bundle(StringIO(bundle_info.get_raw_bundle()))
 
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')
59
64
        reader_method = getattr(bundle_info, 'get_bundle_reader', None)
60
65
        if reader_method is None:
61
66
            raise errors.BzrCommandError('Bundle format not supported')
68
73
                (bytes, parents, repo_kind, revision_id, file_id))
69
74
            if file_id is not None:
70
75
                file_ids.add(file_id)
71
 
        print >> self.outf, 'Records'
 
76
        self.outf.write('Records\n')
72
77
        for kind, records in sorted(by_kind.iteritems()):
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
 
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')
78
84
        nicks = set()
79
85
        committers = set()
80
86
        for revision in bundle_info.real_revisions:
82
88
                nicks.add(revision.properties['branch-nick'])
83
89
            committers.add(revision.committer)
84
90
 
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'))
 
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')))
90
96
        if verbose:
91
 
            print >> self.outf
 
97
            self.outf.write('\n')
92
98
            bundle_file.seek(0)
93
99
            line = bundle_file.readline()
94
100
            line = bundle_file.readline()
95
101
            content = bundle_file.read().decode('bz2')
96
 
            print >> self.outf, "Decoded contents"
 
102
            self.outf.write("Decoded contents\n")
97
103
            self.outf.write(content)
98
 
            print >> self.outf
 
104
            self.outf.write('\n')