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.
683
700
def run(self, dir_list):
684
701
for d in dir_list:
686
702
wt, dd = WorkingTree.open_containing(d)
688
self.outf.write('added %s\n' % d)
703
base = os.path.dirname(dd)
704
id = wt.path2id(base)
708
self.outf.write('added %s\n' % d)
710
raise errors.NotVersionedError(path=base)
691
713
class cmd_relpath(Command):
2667
2689
if old_default_rules is not None:
2668
2690
# dump the rules and exit
2669
2691
for pattern in ignores.OLD_DEFAULTS:
2692
self.outf.write("%s\n" % pattern)
2672
2694
if not name_pattern_list:
2673
2695
raise errors.BzrCommandError("ignore requires at least one "
2689
2711
if id is not None:
2690
2712
filename = entry[0]
2691
2713
if ignored.match(filename):
2692
matches.append(filename.encode('utf-8'))
2714
matches.append(filename)
2694
2716
if len(matches) > 0:
2695
print "Warning: the following files are version controlled and" \
2696
" match your ignore pattern:\n%s" \
2697
"\nThese files will continue to be version controlled" \
2698
" unless you 'bzr remove' them." % ("\n".join(matches),)
2717
self.outf.write("Warning: the following files are version controlled and"
2718
" match your ignore pattern:\n%s"
2719
"\nThese files will continue to be version controlled"
2720
" unless you 'bzr remove' them.\n" % ("\n".join(matches),))
2701
2723
class cmd_ignored(Command):
2740
2762
revno = int(revno)
2741
2763
except ValueError:
2742
raise errors.BzrCommandError("not a valid revision-number: %r" % revno)
2744
print WorkingTree.open_containing(u'.')[0].branch.get_rev_id(revno)
2764
raise errors.BzrCommandError("not a valid revision-number: %r"
2766
revid = WorkingTree.open_containing(u'.')[0].branch.get_rev_id(revno)
2767
self.outf.write("%s\n" % revid)
2747
2770
class cmd_export(Command):
3151
3174
raise errors.BzrCommandError("Commit refused because there are"
3152
3175
" unknown files in the working tree.")
3153
3176
except errors.BoundBranchOutOfDate, e:
3154
raise errors.BzrCommandError(str(e) + "\n"
3155
'To commit to master branch, run update and then commit.\n'
3156
'You can also pass --local to commit to continue working '
3177
e.extra_help = ("\n"
3178
'To commit to master branch, run update and then commit.\n'
3179
'You can also pass --local to commit to continue working '
3160
3184
class cmd_check(Command):
3628
3652
graph = branch1.repository.get_graph(branch2.repository)
3629
3653
base_rev_id = graph.find_unique_lca(last1, last2)
3631
print 'merge base is revision %s' % base_rev_id
3655
self.outf.write('merge base is revision %s\n' % base_rev_id)
3634
3658
class cmd_merge(Command):
4427
4451
doc = '(no description)'
4428
4452
result.append((name_ver, doc, plugin.path()))
4429
4453
for name_ver, doc, path in sorted(result):
4454
self.outf.write("%s\n" % name_ver)
4455
self.outf.write(" %s\n" % doc)
4457
self.outf.write(" %s\n" % path)
4458
self.outf.write("\n")
4437
4461
class cmd_testament(Command):
4717
4741
rev_id = b.get_rev_id(revno)
4719
4743
if rev_id is None or _mod_revision.is_null(rev_id):
4720
ui.ui_factory.note('No revisions to uncommit.')
4744
self.outf.write('No revisions to uncommit.\n')
4723
log_collector = ui.ui_factory.make_output_stream()
4724
4747
lf = log_formatter('short',
4725
to_file=log_collector,
4726
4749
show_timezone='original')
4733
4756
end_revision=last_revno)
4736
ui.ui_factory.note('Dry-run, pretending to remove the above revisions.')
4759
self.outf.write('Dry-run, pretending to remove'
4760
' the above revisions.\n')
4738
ui.ui_factory.note('The above revision(s) will be removed.')
4762
self.outf.write('The above revision(s) will be removed.\n')
4741
if not ui.ui_factory.get_boolean('Are you sure [y/N]? '):
4742
ui.ui_factory.note('Canceled')
4765
if not ui.ui_factory.get_boolean('Are you sure'):
4766
self.outf.write('Canceled')
4745
4769
mutter('Uncommitting from {%s} to {%s}',
4746
4770
last_rev_id, rev_id)
4747
4771
uncommit(b, tree=tree, dry_run=dry_run, verbose=verbose,
4748
4772
revno=revno, local=local)
4749
ui.ui_factory.note('You can restore the old tip by running:\n'
4750
' bzr pull . -r revid:%s' % last_rev_id)
4773
self.outf.write('You can restore the old tip by running:\n'
4774
' bzr pull . -r revid:%s\n' % last_rev_id)
4753
4777
class cmd_break_lock(Command):