~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Jelmer Vernooij
  • Date: 2010-02-17 15:50:09 UTC
  • mfrom: (5042 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5043.
  • Revision ID: jelmer@samba.org-20100217155009-ok2wijesnvly49sg
merge devel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
340
340
    # cat-revision is more for frontends so should be exact
341
341
    encoding = 'strict'
342
342
 
 
343
    def print_revision(self, revisions, revid):
 
344
        stream = revisions.get_record_stream([(revid,)], 'unordered', True)
 
345
        record = stream.next()
 
346
        if record.storage_kind == 'absent':
 
347
            raise errors.NoSuchRevision(revisions, revid)
 
348
        revtext = record.get_bytes_as('fulltext')
 
349
        self.outf.write(revtext.decode('utf-8'))
 
350
 
343
351
    @display_command
344
352
    def run(self, revision_id=None, revision=None):
345
353
        if revision_id is not None and revision is not None:
350
358
                                         ' --revision or a revision_id')
351
359
        b = WorkingTree.open_containing(u'.')[0].branch
352
360
 
353
 
        # TODO: jam 20060112 should cat-revision always output utf-8?
354
 
        if revision_id is not None:
355
 
            revision_id = osutils.safe_revision_id(revision_id, warn=False)
356
 
            try:
357
 
                self.outf.write(b.repository.get_revision_xml(revision_id).decode('utf-8'))
358
 
            except errors.NoSuchRevision:
359
 
                msg = "The repository %s contains no revision %s." % (b.repository.base,
360
 
                    revision_id)
361
 
                raise errors.BzrCommandError(msg)
362
 
        elif revision is not None:
363
 
            for rev in revision:
364
 
                if rev is None:
365
 
                    raise errors.BzrCommandError('You cannot specify a NULL'
366
 
                                                 ' revision.')
367
 
                rev_id = rev.as_revision_id(b)
368
 
                self.outf.write(b.repository.get_revision_xml(rev_id).decode('utf-8'))
 
361
        revisions = b.repository.revisions
 
362
        if revisions is None:
 
363
            raise errors.BzrCommandError('Repository %r does not support '
 
364
                'access to raw revision texts')
369
365
 
 
366
        b.repository.lock_read()
 
367
        try:
 
368
            # TODO: jam 20060112 should cat-revision always output utf-8?
 
369
            if revision_id is not None:
 
370
                revision_id = osutils.safe_revision_id(revision_id, warn=False)
 
371
                try:
 
372
                    self.print_revision(revisions, revision_id)
 
373
                except errors.NoSuchRevision:
 
374
                    msg = "The repository %s contains no revision %s." % (
 
375
                        b.repository.base, revision_id)
 
376
                    raise errors.BzrCommandError(msg)
 
377
            elif revision is not None:
 
378
                for rev in revision:
 
379
                    if rev is None:
 
380
                        raise errors.BzrCommandError(
 
381
                            'You cannot specify a NULL revision.')
 
382
                    rev_id = rev.as_revision_id(b)
 
383
                    self.print_revision(revisions, rev_id)
 
384
        finally:
 
385
            b.repository.unlock()
 
386
        
370
387
 
371
388
class cmd_dump_btree(Command):
372
389
    """Dump the contents of a btree index file to stdout.