/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Robert Collins
  • Date: 2005-10-20 04:08:12 UTC
  • mfrom: (1185.12.68)
  • Revision ID: robertc@robertcollins.net-20051020040812-fecd1bc32aa3478e
Merge from Aaron Bentley.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
import bzrlib
22
22
from bzrlib import BZRDIR
23
 
from bzrlib.commands import Command
 
23
from bzrlib.commands import Command, display_command
24
24
from bzrlib.branch import Branch
25
25
from bzrlib.errors import BzrError, BzrCheckError, BzrCommandError, NotBranchError
26
26
from bzrlib.errors import DivergedBranches
80
80
    takes_options = ['all', 'show-ids']
81
81
    aliases = ['st', 'stat']
82
82
    
 
83
    @display_command
83
84
    def run(self, all=False, show_ids=False, file_list=None, revision=None):
84
85
        if file_list:
85
86
            b, relpath = Branch.open_containing(file_list[0])
110
111
    takes_args = ['revision_id?']
111
112
    takes_options = ['revision']
112
113
    
 
114
    @display_command
113
115
    def run(self, revision_id=None, revision=None):
114
116
 
115
117
        if revision_id is not None and revision is not None:
131
133
    """Show current revision number.
132
134
 
133
135
    This is equal to the number of revisions on this branch."""
 
136
    @display_command
134
137
    def run(self):
135
138
        print Branch.open_containing('.')[0].revno()
136
139
 
141
144
    hidden = True
142
145
    takes_args = ['revision_info*']
143
146
    takes_options = ['revision']
 
147
    @display_command
144
148
    def run(self, revision=None, revision_info_list=[]):
145
149
 
146
150
        revs = []
220
224
    takes_args = ['filename']
221
225
    hidden = True
222
226
    
 
227
    @display_command
223
228
    def run(self, filename):
224
229
        branch, relpath = Branch.open_containing(filename)
225
230
        print relpath
229
234
    """Show inventory of the current working copy or a revision."""
230
235
    takes_options = ['revision', 'show-ids']
231
236
    
 
237
    @display_command
232
238
    def run(self, revision=None, show_ids=False):
233
239
        b = Branch.open_containing('.')[0]
234
240
        if revision is None:
440
446
    # TODO: Only show renames under dir, rather than in the whole branch.
441
447
    takes_args = ['dir?']
442
448
 
 
449
    @display_command
443
450
    def run(self, dir='.'):
444
451
        b = Branch.open_containing(dir)[0]
445
452
        old_inv = b.basis_tree().inventory
455
462
    """Show statistical information about a branch."""
456
463
    takes_args = ['branch?']
457
464
    
 
465
    @display_command
458
466
    def run(self, branch=None):
459
467
        import info
460
468
        b = Branch.open_containing(branch)[0]
486
494
    """
487
495
    hidden = True
488
496
    takes_args = ['filename']
 
497
    @display_command
489
498
    def run(self, filename):
490
499
        b, relpath = Branch.open_containing(filename)
491
500
        i = b.inventory.path2id(relpath)
502
511
    starting at the branch root."""
503
512
    hidden = True
504
513
    takes_args = ['filename']
 
514
    @display_command
505
515
    def run(self, filename):
506
516
        b, relpath = Branch.open_containing(filename)
507
517
        inv = b.inventory
515
525
class cmd_revision_history(Command):
516
526
    """Display list of revision ids on this branch."""
517
527
    hidden = True
 
528
    @display_command
518
529
    def run(self):
519
530
        for patchid in Branch.open_containing('.')[0].revision_history():
520
531
            print patchid
523
534
class cmd_ancestry(Command):
524
535
    """List all revisions merged into this branch."""
525
536
    hidden = True
 
537
    @display_command
526
538
    def run(self):
527
 
        b = find_branch('.')
 
539
        b = Branch.open_containing('.')[0]
528
540
        for revision_id in b.get_ancestry(b.last_revision()):
529
541
            print revision_id
530
542
 
531
543
 
532
544
class cmd_directories(Command):
533
545
    """Display list of versioned directories in this branch."""
 
546
    @display_command
534
547
    def run(self):
535
548
        for name, ie in Branch.open_containing('.')[0].read_working_inventory().directories():
536
549
            if name == '':
585
598
    takes_options = ['revision', 'diff-options']
586
599
    aliases = ['di', 'dif']
587
600
 
 
601
    @display_command
588
602
    def run(self, revision=None, file_list=None, diff_options=None):
589
603
        from bzrlib.diff import show_diff
590
604
 
624
638
    # directories with readdir, rather than stating each one.  Same
625
639
    # level of effort but possibly much less IO.  (Or possibly not,
626
640
    # if the directories are very large...)
 
641
    @display_command
627
642
    def run(self, show_ids=False):
628
643
        b = Branch.open_containing('.')[0]
629
644
        old = b.basis_tree()
639
654
class cmd_modified(Command):
640
655
    """List files modified in working tree."""
641
656
    hidden = True
 
657
    @display_command
642
658
    def run(self):
643
659
        from bzrlib.delta import compare_trees
644
660
 
653
669
class cmd_added(Command):
654
670
    """List files added in working tree."""
655
671
    hidden = True
 
672
    @display_command
656
673
    def run(self):
657
674
        b = Branch.open_containing('.')[0]
658
675
        wt = b.working_tree()
674
691
    The root is the nearest enclosing directory with a .bzr control
675
692
    directory."""
676
693
    takes_args = ['filename?']
 
694
    @display_command
677
695
    def run(self, filename=None):
678
696
        """Print the branch root."""
679
697
        b = Branch.open_containing(filename)[0]
702
720
                            type=str),
703
721
                     Option('short', help='use moderately short format'),
704
722
                     ]
705
 
    
 
723
    @display_command
706
724
    def run(self, filename=None, timezone='original',
707
725
            verbose=False,
708
726
            show_ids=False,
777
795
    A more user-friendly interface is "bzr log FILE"."""
778
796
    hidden = True
779
797
    takes_args = ["filename"]
 
798
    @display_command
780
799
    def run(self, filename):
781
800
        b, relpath = Branch.open_containing(filename)[0]
782
801
        inv = b.read_working_inventory()
790
809
    """
791
810
    # TODO: Take a revision or remote path and list that tree instead.
792
811
    hidden = True
 
812
    @display_command
793
813
    def run(self, revision=None, verbose=False):
794
814
        b, relpath = Branch.open_containing('.')[0]
795
815
        if revision == None:
807
827
 
808
828
class cmd_unknowns(Command):
809
829
    """List unknown files."""
 
830
    @display_command
810
831
    def run(self):
811
832
        from bzrlib.osutils import quotefn
812
833
        for f in Branch.open_containing('.')[0].unknowns():
878
899
    """List ignored files and the patterns that matched them.
879
900
 
880
901
    See also: bzr ignore"""
 
902
    @display_command
881
903
    def run(self):
882
904
        tree = Branch.open_containing('.')[0].working_tree()
883
905
        for path, file_class, kind, file_id, entry in tree.list_files():
897
919
    hidden = True
898
920
    takes_args = ['revno']
899
921
    
 
922
    @display_command
900
923
    def run(self, revno):
901
924
        try:
902
925
            revno = int(revno)
956
979
    takes_options = ['revision']
957
980
    takes_args = ['filename']
958
981
 
 
982
    @display_command
959
983
    def run(self, filename, revision=None):
960
984
        if revision is None:
961
985
            raise BzrCommandError("bzr cat requires a revision number")
968
992
class cmd_local_time_offset(Command):
969
993
    """Show the offset in seconds from GMT to local time."""
970
994
    hidden = True    
 
995
    @display_command
971
996
    def run(self):
972
997
        print bzrlib.osutils.local_time_offset()
973
998
 
1109
1134
    """Show bzr user id."""
1110
1135
    takes_options = ['email']
1111
1136
    
 
1137
    @display_command
1112
1138
    def run(self, email=False):
1113
1139
        try:
1114
1140
            b = bzrlib.branch.Branch.open_containing('.')[0]
1182
1208
 
1183
1209
class cmd_version(Command):
1184
1210
    """Show version of bzr."""
 
1211
    @display_command
1185
1212
    def run(self):
1186
1213
        show_version()
1187
1214
 
1188
1215
class cmd_rocks(Command):
1189
1216
    """Statement of optimism."""
1190
1217
    hidden = True
 
1218
    @display_command
1191
1219
    def run(self):
1192
1220
        print "it sure does!"
1193
1221
 
1200
1228
    takes_args = ['branch', 'other']
1201
1229
    hidden = True
1202
1230
    
 
1231
    @display_command
1203
1232
    def run(self, branch, other):
1204
1233
        from bzrlib.revision import common_ancestor, MultipleRevisionSources
1205
1234
        
1259
1288
    --force is given.
1260
1289
    """
1261
1290
    takes_args = ['branch?']
1262
 
    takes_options = ['revision', 'force', 'merge-type']
 
1291
    takes_options = ['revision', 'force', 'merge-type', 
 
1292
                     Option('show-base', help="Show base revision text in "
 
1293
                            "conflicts")]
1263
1294
 
1264
 
    def run(self, branch=None, revision=None, force=False, 
1265
 
            merge_type=None):
 
1295
    def run(self, branch=None, revision=None, force=False, merge_type=None,
 
1296
            show_base=False):
1266
1297
        from bzrlib.merge import merge
1267
1298
        from bzrlib.merge_core import ApplyMerge3
1268
1299
        if merge_type is None:
1279
1310
        else:
1280
1311
            if len(revision) == 1:
1281
1312
                base = [None, None]
1282
 
                other = [branch, revision[0].in_history(branch).revno]
 
1313
                other_branch = Branch.open_containing(branch)[0]
 
1314
                revno = revision[0].in_history(other_branch).revno
 
1315
                other = [branch, revno]
1283
1316
            else:
1284
1317
                assert len(revision) == 2
1285
1318
                if None in revision:
1286
1319
                    raise BzrCommandError(
1287
1320
                        "Merge doesn't permit that revision specifier.")
1288
 
                b = Branch.open(branch)
 
1321
                b = Branch.open_containing(branch)[0]
1289
1322
 
1290
1323
                base = [branch, revision[0].in_history(b).revno]
1291
1324
                other = [branch, revision[1].in_history(b).revno]
1292
1325
 
1293
1326
        try:
1294
 
            merge(other, base, check_clean=(not force), merge_type=merge_type)
 
1327
            merge(other, base, check_clean=(not force), merge_type=merge_type,
 
1328
                  show_base=show_base)
1295
1329
        except bzrlib.errors.AmbiguousBase, e:
1296
1330
            m = ("sorry, bzr can't determine the right merge base yet\n"
1297
1331
                 "candidates are:\n  "
1351
1385
    takes_args = ['topic?']
1352
1386
    aliases = ['?']
1353
1387
    
 
1388
    @display_command
1354
1389
    def run(self, topic=None, long=False):
1355
1390
        import help
1356
1391
        if topic is None and long:
1366
1401
    aliases = ['s-c']
1367
1402
    hidden = True
1368
1403
    
 
1404
    @display_command
1369
1405
    def run(self, context=None):
1370
1406
        import shellcomplete
1371
1407
        shellcomplete.shellcomplete(context)
1398
1434
    # unknown options are parsed as booleans
1399
1435
    takes_options = ['verbose', 'quiet']
1400
1436
 
 
1437
    @display_command
1401
1438
    def run(self, remote=None, verbose=False, quiet=False):
1402
1439
        from bzrlib.errors import BzrCommandError
1403
1440
        from bzrlib.missing import show_missing
1425
1462
class cmd_plugins(Command):
1426
1463
    """List plugins"""
1427
1464
    hidden = True
 
1465
    @display_command
1428
1466
    def run(self):
1429
1467
        import bzrlib.plugin
1430
1468
        from inspect import getdoc
1445
1483
    """Show testament (signing-form) of a revision."""
1446
1484
    takes_options = ['revision', 'long']
1447
1485
    takes_args = ['branch?']
 
1486
    @display_command
1448
1487
    def run(self, branch='.', revision=None, long=False):
1449
1488
        from bzrlib.testament import Testament
1450
1489
        b = Branch.open_containing(branch)[0]
1482
1521
                     Option('long', help='show date in annotations'),
1483
1522
                     ]
1484
1523
 
 
1524
    @display_command
1485
1525
    def run(self, filename, all=False, long=False):
1486
1526
        from bzrlib.annotate import annotate_file
1487
1527
        b, relpath = Branch.open_containing(filename)