~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

Merge with bzr.dev after 0.8 release.

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
 
65
83
    def can_convert_format(self):
66
84
        """Return true if this bzrdir is one whose format we can convert from."""
67
85
        return True
581
599
                                            self._format._lock_file_name,
582
600
                                            self._format._lock_class)
583
601
 
 
602
    def break_lock(self):
 
603
        """Pre-splitout bzrdirs do not suffer from stale locks."""
 
604
        raise NotImplementedError(self.break_lock)
 
605
 
584
606
    def clone(self, url, revision_id=None, basis=None, force_new_repo=False):
585
607
        """See BzrDir.clone()."""
586
608
        from bzrlib.workingtree import WorkingTreeFormat2
588
610
        result = self._format._initialize_for_clone(url)
589
611
        basis_repo, basis_branch, basis_tree = self._get_basis_components(basis)
590
612
        self.open_repository().clone(result, revision_id=revision_id, basis=basis_repo)
591
 
        self.open_branch().clone(result, revision_id=revision_id)
 
613
        from_branch = self.open_branch()
 
614
        from_branch.clone(result, revision_id=revision_id)
592
615
        try:
593
616
            self.open_workingtree().clone(result, basis=basis_tree)
594
617
        except errors.NotLocalUrl:
596
619
            try:
597
620
                WorkingTreeFormat2().initialize(result)
598
621
            except errors.NotLocalUrl:
599
 
                # but we canot do it for remote trees.
600
 
                pass
 
622
                # but we cannot do it for remote trees.
 
623
                to_branch = result.open_branch()
 
624
                WorkingTreeFormat2().stub_initialize_remote(to_branch.control_files)
601
625
        return result
602
626
 
603
627
    def create_branch(self):