~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

Update test support, and remove deprecated functions pullable_revisions and get_intervening_revisions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
                            rename, splitpath, sha_file,
46
46
                            file_kind, abspath, normpath, pathjoin,
47
47
                            safe_unicode,
 
48
                            rmtree,
48
49
                            )
49
50
from bzrlib.textui import show_status
50
51
from bzrlib.trace import mutter, note
51
52
from bzrlib.tree import EmptyTree, RevisionTree
52
53
from bzrlib.repository import Repository
53
54
from bzrlib.revision import (
54
 
                             get_intervening_revisions,
55
55
                             is_ancestor,
56
56
                             NULL_REVISION,
57
57
                             Revision,
95
95
    def __init__(self, *ignored, **ignored_too):
96
96
        raise NotImplementedError('The Branch class is abstract')
97
97
 
 
98
    def break_lock(self):
 
99
        """Break a lock if one is present from another instance.
 
100
 
 
101
        Uses the ui factory to ask for confirmation if the lock may be from
 
102
        an active process.
 
103
 
 
104
        This will probe the repository for its lock as well.
 
105
        """
 
106
        self.control_files.break_lock()
 
107
        self.repository.break_lock()
 
108
        master = self.get_master_branch()
 
109
        if master is not None:
 
110
            master.break_lock()
 
111
 
98
112
    @staticmethod
99
113
    @deprecated_method(zero_eight)
100
114
    def open_downlevel(base):
154
168
        assert cfg.get_option("nickname") == nick
155
169
 
156
170
    nick = property(_get_nick, _set_nick)
157
 
        
 
171
 
 
172
    def is_locked(self):
 
173
        raise NotImplementedError('is_locked is abstract')
 
174
 
158
175
    def lock_write(self):
159
176
        raise NotImplementedError('lock_write is abstract')
160
 
        
 
177
 
161
178
    def lock_read(self):
162
179
        raise NotImplementedError('lock_read is abstract')
163
180
 
168
185
        """Return lock mode for the Branch: 'r', 'w' or None"""
169
186
        raise NotImplementedError(self.peek_lock_mode)
170
187
 
 
188
    def get_physical_lock_status(self):
 
189
        raise NotImplementedError('get_physical_lock_status is abstract')
 
190
 
171
191
    def abspath(self, name):
172
192
        """Return absolute filename for something in the branch
173
193
        
880
900
        # XXX: cache_root seems to be unused, 2006-01-13 mbp
881
901
        if hasattr(self, 'cache_root') and self.cache_root is not None:
882
902
            try:
883
 
                shutil.rmtree(self.cache_root)
 
903
                rmtree(self.cache_root)
884
904
            except:
885
905
                pass
886
906
            self.cache_root = None
939
959
        tree = self.repository.revision_tree(self.last_revision())
940
960
        return tree.inventory.root.file_id
941
961
 
 
962
    def is_locked(self):
 
963
        return self.control_files.is_locked()
 
964
 
942
965
    def lock_write(self):
943
966
        # TODO: test for failed two phase locks. This is known broken.
944
967
        self.control_files.lock_write()
951
974
 
952
975
    def unlock(self):
953
976
        # TODO: test for failed two phase locks. This is known broken.
954
 
        self.repository.unlock()
955
 
        self.control_files.unlock()
 
977
        try:
 
978
            self.repository.unlock()
 
979
        finally:
 
980
            self.control_files.unlock()
956
981
        
957
982
    def peek_lock_mode(self):
958
983
        if self.control_files._lock_count == 0:
960
985
        else:
961
986
            return self.control_files._lock_mode
962
987
 
 
988
    def get_physical_lock_status(self):
 
989
        return self.control_files.get_physical_lock_status()
 
990
 
963
991
    @needs_read_lock
964
992
    def print_file(self, file, revision_id):
965
993
        """See Branch.print_file."""
1069
1097
        finally:
1070
1098
            other.unlock()
1071
1099
 
1072
 
    @deprecated_method(zero_eight)
1073
 
    def pullable_revisions(self, other, stop_revision):
1074
 
        """Please use bzrlib.missing instead."""
1075
 
        other_revno = other.revision_id_to_revno(stop_revision)
1076
 
        try:
1077
 
            return self.missing_revisions(other, other_revno)
1078
 
        except DivergedBranches, e:
1079
 
            try:
1080
 
                pullable_revs = get_intervening_revisions(self.last_revision(),
1081
 
                                                          stop_revision, 
1082
 
                                                          self.repository)
1083
 
                assert self.last_revision() not in pullable_revs
1084
 
                return pullable_revs
1085
 
            except bzrlib.errors.NotAncestor:
1086
 
                if is_ancestor(self.last_revision(), stop_revision, self):
1087
 
                    return []
1088
 
                else:
1089
 
                    raise e
1090
 
        
1091
1100
    def basis_tree(self):
1092
1101
        """See Branch.basis_tree."""
1093
1102
        return self.repository.revision_tree(self.last_revision())