22
from bzrlib import BZRDIR
23
from bzrlib.commands import Command
24
from bzrlib.branch import Branch
25
from bzrlib.errors import BzrError, BzrCheckError, BzrCommandError, NotBranchError
26
from bzrlib.errors import DivergedBranches
27
from bzrlib.option import Option
28
from bzrlib.revisionspec import RevisionSpec
22
29
import bzrlib.trace
23
30
from bzrlib.trace import mutter, note, log_error, warning
24
from bzrlib.errors import BzrError, BzrCheckError, BzrCommandError, NotBranchError
25
from bzrlib.errors import DivergedBranches
26
from bzrlib.branch import Branch
27
from bzrlib import BZRDIR
28
from bzrlib.commands import Command
31
from bzrlib.workingtree import WorkingTree
31
34
class cmd_status(Command):
692
699
To request a range of logs, you can use the command -r begin:end
693
700
-r revision requests a specific revision, -r :end or -r begin: are
696
--message allows you to give a regular expression, which will be evaluated
697
so that only matching entries will be displayed.
700
704
# TODO: Make --revision support uuid: and hash: [future tag:] notation.
702
706
takes_args = ['filename?']
703
takes_options = ['forward', 'timezone', 'verbose', 'show-ids', 'revision',
704
'long', 'message', 'short',]
707
takes_options = [Option('forward',
708
help='show from oldest to newest'),
709
'timezone', 'verbose',
710
'show-ids', 'revision',
711
Option('line', help='format with one line per revision'),
714
help='show revisions whose message matches this regexp',
716
Option('short', help='use moderately short format'),
706
719
def run(self, filename=None, timezone='original',
714
728
from bzrlib.log import log_formatter, show_log
730
assert message is None or isinstance(message, basestring), \
731
"invalid message argument %r" % message
717
732
direction = (forward and 'forward') or 'reverse'
720
735
b = Branch.open_containing(filename)
721
fp = b.relpath(filename)
736
tree = WorkingTree(b.base, b)
737
fp = tree.relpath(filename)
723
739
file_id = b.read_working_inventory().path2id(fp)
778
795
def run(self, filename):
779
796
b = Branch.open_containing(filename)
780
797
inv = b.read_working_inventory()
781
file_id = inv.path2id(b.relpath(filename))
798
tree = WorkingTree(b.base, b)
799
file_id = inv.path2id(tree.relpath(filename))
782
800
for revno, revision_id, what in bzrlib.log.find_touching_revisions(b, file_id):
783
801
print "%6d %s" % (revno, what)
992
1011
# XXX: verbose currently does nothing
994
1013
takes_args = ['selected*']
995
takes_options = ['message', 'file', 'verbose', 'unchanged']
1014
takes_options = ['message', 'verbose',
1016
help='commit even if nothing has changed'),
1017
Option('file', type=str,
1019
help='file containing commit message'),
996
1021
aliases = ['ci', 'checkin']
998
1023
def run(self, message=None, file=None, verbose=True, selected_list=None,
1117
1142
If arguments are given, they are regular expressions that say
1118
which tests should run."""
1143
which tests should run.
1119
1145
# TODO: --list should give a list of all available tests
1121
1147
takes_args = ['testspecs*']
1122
takes_options = ['verbose']
1123
def run(self, testspecs_list=None, verbose=False):
1148
takes_options = ['verbose',
1149
Option('one', help='stop when one test fails'),
1152
def run(self, testspecs_list=None, verbose=False, one=False):
1124
1153
import bzrlib.ui
1125
1154
from bzrlib.selftest import selftest
1126
1155
# we don't want progress meters from the tests to go to the
1445
1475
class cmd_annotate(Command):
1446
1476
"""Show the origin of each line in a file.
1448
This prints out the given file with an annotation on the
1449
left side indicating which revision, author and date introduced the
1478
This prints out the given file with an annotation on the left side
1479
indicating which revision, author and date introduced the change.
1481
If the origin is the same for a run of consecutive lines, it is
1482
shown only at the top, unless the --all option is given.
1452
1484
# TODO: annotate directories; showing when each file was last changed
1453
1485
# TODO: annotate a previous version of a file
1486
# TODO: if the working copy is modified, show annotations on that
1487
# with new uncommitted lines marked
1454
1488
aliases = ['blame', 'praise']
1455
1489
takes_args = ['filename']
1490
takes_options = [Option('all', help='show annotations on all lines'),
1491
Option('long', help='show date in annotations'),
1457
def run(self, filename):
1494
def run(self, filename, all=False, long=False):
1458
1495
from bzrlib.annotate import annotate_file
1459
1496
b = Branch.open_containing(filename)
1462
rp = b.relpath(filename)
1499
tree = WorkingTree(b.base, b)
1500
rp = tree.relpath(filename)
1463
1501
tree = b.revision_tree(b.last_revision())
1464
1502
file_id = tree.inventory.path2id(rp)
1465
1503
file_version = tree.inventory[file_id].revision
1466
annotate_file(b, file_version, file_id, sys.stdout)
1504
annotate_file(b, file_version, file_id, long, all, sys.stdout)
1509
class cmd_re_sign(Command):
1510
"""Create a digital signature for an existing revision."""
1511
# TODO be able to replace existing ones.
1513
hidden = True # is this right ?
1514
takes_args = ['revision_id?']
1515
takes_options = ['revision']
1517
def run(self, revision_id=None, revision=None):
1518
import bzrlib.config as config
1519
import bzrlib.gpg as gpg
1520
if revision_id is not None and revision is not None:
1521
raise BzrCommandError('You can only supply one of revision_id or --revision')
1522
if revision_id is None and revision is None:
1523
raise BzrCommandError('You must supply either --revision or a revision_id')
1524
b = Branch.open_containing('.')
1525
gpg_strategy = gpg.GPGStrategy(config.BranchConfig(b))
1526
if revision_id is not None:
1527
b.sign_revision(revision_id, gpg_strategy)
1528
elif revision is not None:
1529
for rev in revision:
1531
raise BzrCommandError('You cannot specify a NULL revision.')
1532
revno, rev_id = rev.in_history(b)
1533
b.sign_revision(rev_id, gpg_strategy)
1470
1536
# these get imported and then picked up by the scan for cmd_*
1471
1537
# TODO: Some more consistent way to split command definitions across files;
1472
1538
# we do need to load at least some information about them to know of