~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Robert Collins
  • Date: 2005-10-17 00:00:33 UTC
  • mfrom: (1458)
  • mto: This revision was merged to the branch mainline in revision 1459.
  • Revision ID: robertc@lifelesslap.robertcollins.net-20051017000033-b7385b1772d31605
mergeĀ inĀ integration

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
from bzrlib.branch import Branch
27
27
from bzrlib import BZRDIR
28
28
from bzrlib.commands import Command
 
29
from bzrlib.workingtree import WorkingTree
29
30
 
30
31
 
31
32
class cmd_status(Command):
77
78
    def run(self, all=False, show_ids=False, file_list=None, revision=None):
78
79
        if file_list:
79
80
            b = Branch.open_containing(file_list[0])
80
 
            file_list = [b.relpath(x) for x in file_list]
 
81
            tree = WorkingTree(b.base, b)
 
82
            file_list = [tree.relpath(x) for x in file_list]
81
83
            # special case: only one path was given and it's the root
82
84
            # of the branch
83
85
            if file_list == ['']:
214
216
    hidden = True
215
217
    
216
218
    def run(self, filename):
217
 
        print Branch.open_containing(filename).relpath(filename)
218
 
 
 
219
        branch = Branch.open_containing(filename)
 
220
        print WorkingTree(branch.base, branch).relpath(filename)
219
221
 
220
222
 
221
223
class cmd_inventory(Command):
252
254
        b = Branch.open_containing('.')
253
255
 
254
256
        # TODO: glob expansion on windows?
255
 
        b.move([b.relpath(s) for s in source_list], b.relpath(dest))
 
257
        tree = WorkingTree(b.base, b)
 
258
        b.move([tree.relpath(s) for s in source_list], tree.relpath(dest))
256
259
 
257
260
 
258
261
class cmd_rename(Command):
273
276
    
274
277
    def run(self, from_name, to_name):
275
278
        b = Branch.open_containing('.')
276
 
        b.rename_one(b.relpath(from_name), b.relpath(to_name))
277
 
 
 
279
        tree = WorkingTree(b.base, b)
 
280
        b.rename_one(tree.relpath(from_name), tree.relpath(to_name))
278
281
 
279
282
 
280
283
class cmd_mv(Command):
295
298
        if len(names_list) < 2:
296
299
            raise BzrCommandError("missing file argument")
297
300
        b = Branch.open_containing(names_list[0])
298
 
 
299
 
        rel_names = [b.relpath(x) for x in names_list]
 
301
        tree = WorkingTree(b.base, b)
 
302
        rel_names = [tree.relpath(x) for x in names_list]
300
303
        
301
304
        if os.path.isdir(names_list[-1]):
302
305
            # move into existing directory
481
484
    
482
485
    def run(self, file_list, verbose=False):
483
486
        b = Branch.open_containing(file_list[0])
484
 
        b.remove([b.relpath(f) for f in file_list], verbose=verbose)
 
487
        tree = WorkingTree(b.base, b)
 
488
        b.remove([tree.relpath(f) for f in file_list], verbose=verbose)
485
489
 
486
490
 
487
491
class cmd_file_id(Command):
495
499
    takes_args = ['filename']
496
500
    def run(self, filename):
497
501
        b = Branch.open_containing(filename)
498
 
        i = b.inventory.path2id(b.relpath(filename))
 
502
        tree = WorkingTree(b.base, b)
 
503
        i = b.inventory.path2id(tree.relpath(filename))
499
504
        if i == None:
500
505
            raise BzrError("%r is not a versioned file" % filename)
501
506
        else:
512
517
    def run(self, filename):
513
518
        b = Branch.open_containing(filename)
514
519
        inv = b.inventory
515
 
        fid = inv.path2id(b.relpath(filename))
 
520
        tree = WorkingTree(b.base, b)
 
521
        fid = inv.path2id(tree.relpath(filename))
516
522
        if fid == None:
517
523
            raise BzrError("%r is not a versioned file" % filename)
518
524
        for fip in inv.get_idpath(fid):
597
603
 
598
604
        if file_list:
599
605
            b = Branch.open_containing(file_list[0])
600
 
            file_list = [b.relpath(f) for f in file_list]
 
606
            tree = WorkingTree(b.base, b)
 
607
            file_list = [tree.relpath(f) for f in file_list]
601
608
            if file_list == ['']:
602
609
                # just pointing to top-of-tree
603
610
                file_list = None
718
725
        
719
726
        if filename:
720
727
            b = Branch.open_containing(filename)
721
 
            fp = b.relpath(filename)
 
728
            tree = WorkingTree(b.base, b)
 
729
            fp = tree.relpath(filename)
722
730
            if fp:
723
731
                file_id = b.read_working_inventory().path2id(fp)
724
732
            else:
778
786
    def run(self, filename):
779
787
        b = Branch.open_containing(filename)
780
788
        inv = b.read_working_inventory()
781
 
        file_id = inv.path2id(b.relpath(filename))
 
789
        tree = WorkingTree(b.base, b)
 
790
        file_id = inv.path2id(tree.relpath(filename))
782
791
        for revno, revision_id, what in bzrlib.log.find_touching_revisions(b, file_id):
783
792
            print "%6d %s" % (revno, what)
784
793
 
960
969
        elif len(revision) != 1:
961
970
            raise BzrCommandError("bzr cat --revision takes exactly one number")
962
971
        b = Branch.open_containing('.')
963
 
        b.print_file(b.relpath(filename), revision[0].in_history(b).revno)
 
972
        tree = WorkingTree(b.base, b)
 
973
        b.print_file(tree.relpath(filename), revision[0].in_history(b).revno)
964
974
 
965
975
 
966
976
class cmd_local_time_offset(Command):
1003
1013
        from cStringIO import StringIO
1004
1014
 
1005
1015
        b = Branch.open_containing('.')
 
1016
        tree = WorkingTree(b.base, b)
1006
1017
        if selected_list:
1007
 
            selected_list = [b.relpath(s) for s in selected_list]
1008
 
 
 
1018
            selected_list = [tree.relpath(s) for s in selected_list]
1009
1019
            
1010
1020
        if message is None and not file:
1011
1021
            catcher = StringIO()
1460
1470
        b = Branch.open_containing(filename)
1461
1471
        b.lock_read()
1462
1472
        try:
1463
 
            rp = b.relpath(filename)
 
1473
            tree = WorkingTree(b.base, b)
 
1474
            rp = tree.relpath(filename)
1464
1475
            tree = b.revision_tree(b.last_revision())
1465
1476
            file_id = tree.inventory.path2id(rp)
1466
1477
            file_version = tree.inventory[file_id].revision