~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bundle/commands.py

  • Committer: Aaron Bentley
  • Date: 2007-06-15 14:18:04 UTC
  • mto: (2520.5.2 bzr.mpbundle)
  • mto: This revision was merged to the branch mainline in revision 2631.
  • Revision ID: abentley@panoramicfeedback.com-20070615141804-kqturh52i2e2aa1l
zap obsolete changeset commands, add bundle-info command

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
    branch,
29
29
    errors,
30
30
    urlutils,
 
31
    transport,
31
32
    )
32
33
from bzrlib.revision import common_ancestor
33
34
""")
37
38
from bzrlib.trace import note
38
39
 
39
40
 
40
 
class cmd_send_changeset(Command):
41
 
    """Send a bundled up changset via mail.
42
 
 
43
 
    If no revision has been specified, the last commited change will
44
 
    be sent.
45
 
 
46
 
    Subject of the mail can be specified by the --message option,
47
 
    otherwise information from the changeset log will be used.
48
 
 
49
 
    A editor will be spawned where the user may enter a description
50
 
    of the changeset.  The description can be read from a file with
51
 
    the --file FILE option.
52
 
    """
53
 
    takes_options = ['revision', 'message', 'file']
54
 
    takes_args = ['to?']
55
 
 
56
 
    def run(self, to=None, message=None, revision=None, file=None):
57
 
        from bzrlib.errors import BzrCommandError
58
 
        from send_changeset import send_changeset
59
 
        
60
 
        if isinstance(revision, (list, tuple)):
61
 
            if len(revision) > 1:
62
 
                raise BzrCommandError('We do not support rollup-changesets yet.')
63
 
            revision = revision[0]
64
 
 
65
 
        b = branch.Branch.open_containing('.')
66
 
 
67
 
        if not to:
68
 
            try:
69
 
                to = b.controlfile('x-send-address', 'rb').read().strip('\n')
70
 
            except:
71
 
                raise BzrCommandError('destination address is not known')
72
 
 
73
 
        if not isinstance(revision, (list, tuple)):
74
 
            revision = [revision]
75
 
 
76
 
        send_changeset(b, revision, to, message, file)
77
 
 
78
 
 
79
41
class cmd_bundle_revisions(Command):
80
42
    """Generate a revision bundle.
81
43
 
172
134
            target_branch.repository.unlock()
173
135
 
174
136
 
175
 
class cmd_verify_changeset(Command):
176
 
    """Read a written changeset, and make sure it is valid.
177
 
 
178
 
    """
179
 
    takes_args = ['filename?']
180
 
 
181
 
    def run(self, filename=None):
182
 
        from read_changeset import read_changeset
183
 
        #from bzrlib.xml import serializer_v4
184
 
 
185
 
        b, relpath = branch.Branch.open_containing('.')
186
 
 
187
 
        if filename is None or filename == '-':
188
 
            f = sys.stdin
189
 
        else:
190
 
            f = open(filename, 'U')
191
 
 
192
 
        cset_info, cset_tree = read_changeset(f, b)
193
 
        # print cset_info
194
 
        # print cset_tree
195
 
        #serializer_v4.write(cset_tree.inventory, sys.stdout)
 
137
class cmd_bundle_info(Command):
 
138
    """Output interesting info about a bundle"""
 
139
 
 
140
    hidden = True
 
141
    takes_args = ['location']
 
142
    takes_options = ['verbose']
 
143
 
 
144
    def run(self, location, verbose=False):
 
145
        from bzrlib.bundle.serializer import read_bundle
 
146
        dirname, basename = urlutils.split(location)
 
147
        bundle_file = transport.get_transport(dirname).get(basename)
 
148
        bundle_info = read_bundle(bundle_file)
 
149
        reader_method = getattr(bundle_info, 'get_bundle_reader', None)
 
150
        if reader_method is None:
 
151
            raise errors.BzrCommandError('Bundle format not supported')
 
152
 
 
153
        by_kind = {}
 
154
        file_ids = set()
 
155
        for bytes, parents, repo_kind, revision_id, file_id\
 
156
            in reader_method().iter_records():
 
157
            by_kind.setdefault(repo_kind, []).append(
 
158
                (bytes, parents, repo_kind, revision_id, file_id))
 
159
            if file_id is not None:
 
160
                file_ids.add(file_id)
 
161
        print >> self.outf, 'Records'
 
162
        for kind, records in sorted(by_kind.iteritems()):
 
163
            multiparent = sum(1 for b, p, k, r, f in records if len(p) > 1)
 
164
            print >> self.outf, '%s: %d (%d multiparent)' % \
 
165
                (kind, len(records), multiparent)
 
166
        print >> self.outf, 'unique files: %d' % len(file_ids)
 
167
        print >> self.outf
 
168
        nicks = set()
 
169
        committers = set()
 
170
        for revision in bundle_info.real_revisions:
 
171
            nicks.add(revision.properties['branch-nick'])
 
172
            committers.add(revision.committer)
 
173
 
 
174
        print >> self.outf, 'Revisions'
 
175
        print >> self.outf, 'nicks: %s' % ', '.join(sorted(nicks))
 
176
        print >> self.outf, 'committers: \n%s' % '\n'.join(sorted(committers))
 
177
        if verbose:
 
178
            print >> self.outf
 
179
            bundle_file.seek(0)
 
180
            bundle_file.readline()
 
181
            bundle_file.readline()
 
182
            content = bundle_file.read().decode('base-64').decode('bz2')
 
183
            print >> self.outf, "Decoded contents"
 
184
            self.outf.write(content)