340
340
# cat-revision is more for frontends so should be exact
341
341
encoding = 'strict'
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'))
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
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)
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,
361
raise errors.BzrCommandError(msg)
362
elif revision is not None:
365
raise errors.BzrCommandError('You cannot specify a NULL'
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')
366
b.repository.lock_read()
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)
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:
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)
385
b.repository.unlock()
371
388
class cmd_dump_btree(Command):
372
389
"""Dump the contents of a btree index file to stdout.