~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

[merge] from robert

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
from bzrlib import BZRDIR
28
28
from bzrlib.commands import Command
29
29
from bzrlib.option import Option
 
30
from bzrlib.workingtree import WorkingTree
 
31
 
30
32
 
31
33
class cmd_status(Command):
32
34
    """Display status summary.
77
79
    def run(self, all=False, show_ids=False, file_list=None, revision=None):
78
80
        if file_list:
79
81
            b = Branch.open_containing(file_list[0])
80
 
            file_list = [b.relpath(x) for x in file_list]
 
82
            tree = WorkingTree(b.base, b)
 
83
            file_list = [tree.relpath(x) for x in file_list]
81
84
            # special case: only one path was given and it's the root
82
85
            # of the branch
83
86
            if file_list == ['']:
214
217
    hidden = True
215
218
    
216
219
    def run(self, filename):
217
 
        print Branch.open_containing(filename).relpath(filename)
218
 
 
 
220
        branch = Branch.open_containing(filename)
 
221
        print WorkingTree(branch.base, branch).relpath(filename)
219
222
 
220
223
 
221
224
class cmd_inventory(Command):
252
255
        b = Branch.open_containing('.')
253
256
 
254
257
        # TODO: glob expansion on windows?
255
 
        b.move([b.relpath(s) for s in source_list], b.relpath(dest))
 
258
        tree = WorkingTree(b.base, b)
 
259
        b.move([tree.relpath(s) for s in source_list], tree.relpath(dest))
256
260
 
257
261
 
258
262
class cmd_rename(Command):
273
277
    
274
278
    def run(self, from_name, to_name):
275
279
        b = Branch.open_containing('.')
276
 
        b.rename_one(b.relpath(from_name), b.relpath(to_name))
277
 
 
 
280
        tree = WorkingTree(b.base, b)
 
281
        b.rename_one(tree.relpath(from_name), tree.relpath(to_name))
278
282
 
279
283
 
280
284
class cmd_mv(Command):
295
299
        if len(names_list) < 2:
296
300
            raise BzrCommandError("missing file argument")
297
301
        b = Branch.open_containing(names_list[0])
298
 
 
299
 
        rel_names = [b.relpath(x) for x in names_list]
 
302
        tree = WorkingTree(b.base, b)
 
303
        rel_names = [tree.relpath(x) for x in names_list]
300
304
        
301
305
        if os.path.isdir(names_list[-1]):
302
306
            # move into existing directory
481
485
    
482
486
    def run(self, file_list, verbose=False):
483
487
        b = Branch.open_containing(file_list[0])
484
 
        b.remove([b.relpath(f) for f in file_list], verbose=verbose)
 
488
        tree = WorkingTree(b.base, b)
 
489
        b.remove([tree.relpath(f) for f in file_list], verbose=verbose)
485
490
 
486
491
 
487
492
class cmd_file_id(Command):
495
500
    takes_args = ['filename']
496
501
    def run(self, filename):
497
502
        b = Branch.open_containing(filename)
498
 
        i = b.inventory.path2id(b.relpath(filename))
 
503
        tree = WorkingTree(b.base, b)
 
504
        i = b.inventory.path2id(tree.relpath(filename))
499
505
        if i == None:
500
506
            raise BzrError("%r is not a versioned file" % filename)
501
507
        else:
512
518
    def run(self, filename):
513
519
        b = Branch.open_containing(filename)
514
520
        inv = b.inventory
515
 
        fid = inv.path2id(b.relpath(filename))
 
521
        tree = WorkingTree(b.base, b)
 
522
        fid = inv.path2id(tree.relpath(filename))
516
523
        if fid == None:
517
524
            raise BzrError("%r is not a versioned file" % filename)
518
525
        for fip in inv.get_idpath(fid):
597
604
 
598
605
        if file_list:
599
606
            b = Branch.open_containing(file_list[0])
600
 
            file_list = [b.relpath(f) for f in file_list]
 
607
            tree = WorkingTree(b.base, b)
 
608
            file_list = [tree.relpath(f) for f in file_list]
601
609
            if file_list == ['']:
602
610
                # just pointing to top-of-tree
603
611
                file_list = None
723
731
        
724
732
        if filename:
725
733
            b = Branch.open_containing(filename)
726
 
            fp = b.relpath(filename)
 
734
            tree = WorkingTree(b.base, b)
 
735
            fp = tree.relpath(filename)
727
736
            if fp:
728
737
                file_id = b.read_working_inventory().path2id(fp)
729
738
            else:
783
792
    def run(self, filename):
784
793
        b = Branch.open_containing(filename)
785
794
        inv = b.read_working_inventory()
786
 
        file_id = inv.path2id(b.relpath(filename))
 
795
        tree = WorkingTree(b.base, b)
 
796
        file_id = inv.path2id(tree.relpath(filename))
787
797
        for revno, revision_id, what in bzrlib.log.find_touching_revisions(b, file_id):
788
798
            print "%6d %s" % (revno, what)
789
799
 
965
975
        elif len(revision) != 1:
966
976
            raise BzrCommandError("bzr cat --revision takes exactly one number")
967
977
        b = Branch.open_containing('.')
968
 
        b.print_file(b.relpath(filename), revision[0].in_history(b).revno)
 
978
        tree = WorkingTree(b.base, b)
 
979
        b.print_file(tree.relpath(filename), revision[0].in_history(b).revno)
969
980
 
970
981
 
971
982
class cmd_local_time_offset(Command):
1014
1025
        from cStringIO import StringIO
1015
1026
 
1016
1027
        b = Branch.open_containing('.')
 
1028
        tree = WorkingTree(b.base, b)
1017
1029
        if selected_list:
1018
 
            selected_list = [b.relpath(s) for s in selected_list]
1019
 
 
 
1030
            selected_list = [tree.relpath(s) for s in selected_list]
1020
1031
        if message is None and not file:
1021
1032
            catcher = StringIO()
1022
1033
            show_status(b, specific_files=selected_list,
1057
1068
    detect data corruption or bzr bugs.
1058
1069
    """
1059
1070
    takes_args = ['dir?']
 
1071
    takes_options = ['verbose']
1060
1072
 
1061
 
    def run(self, dir='.'):
 
1073
    def run(self, dir='.', verbose=False):
1062
1074
        from bzrlib.check import check
1063
 
 
1064
 
        check(Branch.open_containing(dir))
 
1075
        check(Branch.open_containing(dir), verbose)
1065
1076
 
1066
1077
 
1067
1078
class cmd_scan_cache(Command):
1107
1118
    def run(self, email=False):
1108
1119
        try:
1109
1120
            b = bzrlib.branch.Branch.open_containing('.')
 
1121
            config = bzrlib.config.BranchConfig(b)
1110
1122
        except NotBranchError:
1111
 
            b = None
 
1123
            config = bzrlib.config.GlobalConfig()
1112
1124
        
1113
1125
        if email:
1114
 
            print bzrlib.config.user_email(b)
 
1126
            print config.user_email()
1115
1127
        else:
1116
 
            print bzrlib.config.username(b)
 
1128
            print config.username()
1117
1129
 
1118
1130
 
1119
1131
class cmd_selftest(Command):
1476
1488
        b = Branch.open_containing(filename)
1477
1489
        b.lock_read()
1478
1490
        try:
1479
 
            rp = b.relpath(filename)
 
1491
            tree = WorkingTree(b.base, b)
 
1492
            rp = tree.relpath(filename)
1480
1493
            tree = b.revision_tree(b.last_revision())
1481
1494
            file_id = tree.inventory.path2id(rp)
1482
1495
            file_version = tree.inventory[file_id].revision