~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Robert Collins
  • Date: 2009-04-15 05:39:38 UTC
  • mto: This revision was merged to the branch mainline in revision 4292.
  • Revision ID: robertc@robertcollins.net-20090415053938-9w379adk8993sq1q
Hopefully fix locking tests to match the new code (and still be good statements of intent).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1931
1931
 
1932
1932
    def lock_write(self, token=None):
1933
1933
        repo_control = getattr(self.repository, 'control_files', None)
1934
 
        if self.control_files is repo_control or not self.is_locked():
 
1934
        if self.control_files == repo_control or not self.is_locked():
1935
1935
            self.repository.lock_write()
1936
1936
            took_lock = True
1937
1937
        else:
1945
1945
 
1946
1946
    def lock_read(self):
1947
1947
        repo_control = getattr(self.repository, 'control_files', None)
1948
 
        if self.control_files is repo_control or not self.is_locked():
 
1948
        if self.control_files == repo_control or not self.is_locked():
1949
1949
            self.repository.lock_read()
1950
1950
            took_lock = True
1951
1951
        else:
1958
1958
            raise
1959
1959
 
1960
1960
    def unlock(self):
1961
 
        self.control_files.unlock()
1962
 
        repo_control = getattr(self.repository, 'control_files', None)
1963
 
        if (self.control_files is repo_control or
1964
 
            not self.control_files.is_locked()):
1965
 
            self.repository.unlock()
1966
 
        if not self.control_files.is_locked():
1967
 
            # we just released the lock
1968
 
            self._clear_cached_state()
 
1961
        try:
 
1962
            self.control_files.unlock()
 
1963
        finally:
 
1964
            repo_control = getattr(self.repository, 'control_files', None)
 
1965
            if (self.control_files == repo_control or
 
1966
                not self.control_files.is_locked()):
 
1967
                self.repository.unlock()
 
1968
            if not self.control_files.is_locked():
 
1969
                # we just released the lock
 
1970
                self._clear_cached_state()
1969
1971
 
1970
1972
    def peek_lock_mode(self):
1971
1973
        if self.control_files._lock_count == 0: