~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

Merge in bzr-dir phase 2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import sys
22
22
 
23
23
import bzrlib
24
 
from bzrlib import BZRDIR
 
24
import bzrlib.bzrdir as bzrdir
25
25
from bzrlib._merge_core import ApplyMerge3
26
26
from bzrlib.commands import Command, display_command
27
27
from bzrlib.branch import Branch
572
572
        br_from.lock_read()
573
573
        try:
574
574
            if basis is not None:
575
 
                basis_branch = WorkingTree.open_containing(basis)[0].branch
 
575
                basis_dir = bzrdir.BzrDir.open_containing(basis)[0]
576
576
            else:
577
 
                basis_branch = None
 
577
                basis_dir = None
578
578
            if len(revision) == 1 and revision[0] is not None:
579
579
                revision_id = revision[0].in_history(br_from)[1]
580
580
            else:
581
 
                revision_id = None
 
581
                # FIXME - wt.last_revision, fallback to branch, fall back to
 
582
                # None or perhaps NULL_REVISION to mean copy nothing
 
583
                # RBC 20060209
 
584
                revision_id = br_from.last_revision()
582
585
            if to_location is None:
583
586
                to_location = os.path.basename(from_location.rstrip("/\\"))
584
587
                name = None
596
599
                else:
597
600
                    raise
598
601
            try:
599
 
                br_from.clone(to_location, revision_id, basis_branch)
 
602
                dir = br_from.bzrdir.sprout(to_location, revision_id, basis_dir)
 
603
                branch = dir.open_branch()
600
604
            except bzrlib.errors.NoSuchRevision:
601
605
                rmtree(to_location)
602
606
                msg = "The branch %s has no revision %s." % (from_location, revision[0])
605
609
                rmtree(to_location)
606
610
                msg = "The branch %s cannot be used as a --basis"
607
611
                raise BzrCommandError(msg)
608
 
            branch = Branch.open(to_location)
 
612
            WorkingTree.create(branch, to_location)
609
613
            if name:
610
614
                branch.control_files.put_utf8('branch-name', name)
611
615
 
625
629
    @display_command
626
630
    def run(self, dir=u'.'):
627
631
        tree = WorkingTree.open_containing(dir)[0]
628
 
        old_inv = tree.branch.basis_tree().inventory
 
632
        old_inv = tree.basis_tree().inventory
629
633
        new_inv = tree.read_working_inventory()
630
634
 
631
635
        renames = list(bzrlib.tree.find_renames(old_inv, new_inv))
827
831
    @display_command
828
832
    def run(self, show_ids=False):
829
833
        tree = WorkingTree.open_containing(u'.')[0]
830
 
        old = tree.branch.basis_tree()
 
834
        old = tree.basis_tree()
831
835
        for path, ie in old.inventory.iter_entries():
832
836
            if not tree.has_id(ie.file_id):
833
837
                if show_ids:
844
848
        from bzrlib.delta import compare_trees
845
849
 
846
850
        tree = WorkingTree.open_containing(u'.')[0]
847
 
        td = compare_trees(tree.branch.basis_tree(), tree)
 
851
        td = compare_trees(tree.basis_tree(), tree)
848
852
 
849
853
        for path, id, kind, text_modified, meta_modified in td.modified:
850
854
            print path
857
861
    @display_command
858
862
    def run(self):
859
863
        wt = WorkingTree.open_containing(u'.')[0]
860
 
        basis_inv = wt.branch.basis_tree().inventory
 
864
        basis_inv = wt.basis_tree().inventory
861
865
        inv = wt.inventory
862
866
        for file_id in inv:
863
867
            if file_id in basis_inv:
919
923
            "invalid message argument %r" % message
920
924
        direction = (forward and 'forward') or 'reverse'
921
925
        
 
926
        # log everything
 
927
        file_id = None
922
928
        if filename:
923
 
            # might be a tree:
924
 
            tree = None
925
 
            try:
926
 
                tree, fp = WorkingTree.open_containing(filename)
927
 
                b = tree.branch
928
 
                if fp != '':
929
 
                    inv = tree.read_working_inventory()
930
 
            except NotBranchError:
931
 
                pass
932
 
            if tree is None:
933
 
                b, fp = Branch.open_containing(filename)
934
 
                if fp != '':
935
 
                    inv = b.repository.get_inventory(b.last_revision())
 
929
            # find the file id to log:
 
930
 
 
931
            dir, fp = bzrdir.BzrDir.open_containing(filename)
 
932
            b = dir.open_branch()
936
933
            if fp != '':
 
934
                try:
 
935
                    # might be a tree:
 
936
                    inv = dir.open_workingtree().inventory
 
937
                except (errors.NotBranchError, errors.NotLocalUrl):
 
938
                    # either no tree, or is remote.
 
939
                    inv = b.basis_tree().inventory
937
940
                file_id = inv.path2id(fp)
938
 
            else:
939
 
                file_id = None  # points to branch root
940
941
        else:
941
 
            tree, relpath = WorkingTree.open_containing(u'.')
942
 
            b = tree.branch
943
 
            file_id = None
 
942
            # local dir only
 
943
            # FIXME ? log the current subdir only RBC 20060203 
 
944
            dir, relpath = bzrdir.BzrDir.open_containing('.')
 
945
            b = dir.open_branch()
944
946
 
945
947
        if revision is None:
946
948
            rev1 = None
984
986
                 end_revision=rev2,
985
987
                 search=message)
986
988
 
 
989
 
987
990
def get_log_format(long=False, short=False, line=False, default='long'):
988
991
    log_format = default
989
992
    if long:
1705
1708
                    
1706
1709
                    for name, ie in tree.inventory.iter_entries(file_id):
1707
1710
                        interesting_ids.add(ie.file_id)
1708
 
            transform_tree(tree, tree.branch.basis_tree(), interesting_ids)
 
1711
            transform_tree(tree, tree.basis_tree(), interesting_ids)
1709
1712
            if file_list is None:
1710
1713
                restore_files = list(tree.iter_conflicts())
1711
1714
            else: