~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

  • Committer: Robert Collins
  • Date: 2006-04-19 23:32:08 UTC
  • mto: (1711.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1674.
  • Revision ID: robertc@robertcollins.net-20060419233208-2ed6906796994316
Make knit the default format.
Adjust affect tests to either have knit specific values or to be more generic,
as appropriate.
Disable all SFTP prefetching for known paramikos - direct readv support is now
a TODO.

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
        a transport connected to the directory this bzr was opened from.
63
63
    """
64
64
 
65
 
    def break_lock(self):
66
 
        """Invoke break_lock on the first object in the bzrdir.
67
 
 
68
 
        If there is a tree, the tree is opened and break_lock() called.
69
 
        Otherwise, branch is tried, and finally repository.
70
 
        """
71
 
        try:
72
 
            thing_to_unlock = self.open_workingtree()
73
 
        except (errors.NotLocalUrl, errors.NoWorkingTree):
74
 
            try:
75
 
                thing_to_unlock = self.open_branch()
76
 
            except errors.NotBranchError:
77
 
                try:
78
 
                    thing_to_unlock = self.open_repository()
79
 
                except errors.NoRepositoryPresent:
80
 
                    return
81
 
        thing_to_unlock.break_lock()
82
 
 
83
65
    def can_convert_format(self):
84
66
        """Return true if this bzrdir is one whose format we can convert from."""
85
67
        return True
118
100
        if local_repo:
119
101
            # may need to copy content in
120
102
            if force_new_repo:
121
 
                result_repo = local_repo.clone(
122
 
                    result,
123
 
                    revision_id=revision_id,
124
 
                    basis=basis_repo)
125
 
                result_repo.set_make_working_trees(local_repo.make_working_trees())
 
103
                local_repo.clone(result, revision_id=revision_id, basis=basis_repo)
126
104
            else:
127
105
                try:
128
106
                    result_repo = result.find_repository()
134
112
                    result_repo.fetch(local_repo, revision_id=revision_id)
135
113
                except errors.NoRepositoryPresent:
136
114
                    # needed to make one anyway.
137
 
                    result_repo = local_repo.clone(
138
 
                        result,
139
 
                        revision_id=revision_id,
140
 
                        basis=basis_repo)
141
 
                    result_repo.set_make_working_trees(local_repo.make_working_trees())
 
115
                    local_repo.clone(result, revision_id=revision_id, basis=basis_repo)
142
116
        # 1 if there is a branch present
143
117
        #   make sure its content is available in the target repository
144
118
        #   clone it.
505
479
        """
506
480
        raise NotImplementedError(self.open_workingtree)
507
481
 
508
 
    def has_branch(self):
509
 
        """Tell if this bzrdir contains a branch.
510
 
        
511
 
        Note: if you're going to open the branch, you should just go ahead
512
 
        and try, and not ask permission first.  (This method just opens the 
513
 
        branch and discards it, and that's somewhat expensive.) 
514
 
        """
515
 
        try:
516
 
            self.open_branch()
517
 
            return True
518
 
        except errors.NotBranchError:
519
 
            return False
520
 
 
521
 
    def has_workingtree(self):
522
 
        """Tell if this bzrdir contains a working tree.
523
 
 
524
 
        This will still raise an exception if the bzrdir has a workingtree that
525
 
        is remote & inaccessible.
526
 
        
527
 
        Note: if you're going to open the working tree, you should just go ahead
528
 
        and try, and not ask permission first.  (This method just opens the 
529
 
        workingtree and discards it, and that's somewhat expensive.) 
530
 
        """
531
 
        try:
532
 
            self.open_workingtree()
533
 
            return True
534
 
        except errors.NoWorkingTree:
535
 
            return False
536
 
 
537
482
    def sprout(self, url, revision_id=None, basis=None, force_new_repo=False):
538
483
        """Create a copy of this bzrdir prepared for use as a new line of
539
484
        development.
575
520
            # no repo available, make a new one
576
521
            result.create_repository()
577
522
        elif source_repository is not None and result_repo is None:
578
 
            # have source, and want to make a new target repo
579
 
            # we dont clone the repo because that preserves attributes
580
 
            # like is_shared(), and we have not yet implemented a 
581
 
            # repository sprout().
582
 
            result_repo = result.create_repository()
583
 
        if result_repo is not None:
 
523
            # have soure, and want to make a new target repo
 
524
            source_repository.clone(result,
 
525
                                    revision_id=revision_id,
 
526
                                    basis=basis_repo)
 
527
        else:
584
528
            # fetch needed content into target.
585
529
            if basis_repo:
586
530
                # XXX FIXME RBC 20060214 need tests for this when the basis
608
552
                                            self._format._lock_file_name,
609
553
                                            self._format._lock_class)
610
554
 
611
 
    def break_lock(self):
612
 
        """Pre-splitout bzrdirs do not suffer from stale locks."""
613
 
        raise NotImplementedError(self.break_lock)
614
 
 
615
555
    def clone(self, url, revision_id=None, basis=None, force_new_repo=False):
616
556
        """See BzrDir.clone()."""
617
557
        from bzrlib.workingtree import WorkingTreeFormat2
619
559
        result = self._format._initialize_for_clone(url)
620
560
        basis_repo, basis_branch, basis_tree = self._get_basis_components(basis)
621
561
        self.open_repository().clone(result, revision_id=revision_id, basis=basis_repo)
622
 
        from_branch = self.open_branch()
623
 
        from_branch.clone(result, revision_id=revision_id)
 
562
        self.open_branch().clone(result, revision_id=revision_id)
624
563
        try:
625
564
            self.open_workingtree().clone(result, basis=basis_tree)
626
565
        except errors.NotLocalUrl:
628
567
            try:
629
568
                WorkingTreeFormat2().initialize(result)
630
569
            except errors.NotLocalUrl:
631
 
                # but we cannot do it for remote trees.
632
 
                to_branch = result.open_branch()
633
 
                WorkingTreeFormat2().stub_initialize_remote(to_branch.control_files)
 
570
                # but we canot do it for remote trees.
 
571
                pass
634
572
        return result
635
573
 
636
574
    def create_branch(self):