~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-07-09 16:17:45 UTC
  • mfrom: (1711.8.7 two-phase-locking)
  • Revision ID: pqm@pqm.ubuntu.com-20060709161745-764d41910ae59c5e
(jam) update Branch and WorkingTree to properly lock and cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
993
993
        return self.control_files.is_locked()
994
994
 
995
995
    def lock_write(self):
996
 
        # TODO: test for failed two phase locks. This is known broken.
997
 
        self.control_files.lock_write()
998
996
        self.repository.lock_write()
 
997
        try:
 
998
            self.control_files.lock_write()
 
999
        except:
 
1000
            self.repository.unlock()
 
1001
            raise
999
1002
 
1000
1003
    def lock_read(self):
1001
 
        # TODO: test for failed two phase locks. This is known broken.
1002
 
        self.control_files.lock_read()
1003
1004
        self.repository.lock_read()
 
1005
        try:
 
1006
            self.control_files.lock_read()
 
1007
        except:
 
1008
            self.repository.unlock()
 
1009
            raise
1004
1010
 
1005
1011
    def unlock(self):
1006
1012
        # TODO: test for failed two phase locks. This is known broken.
1007
1013
        try:
1008
 
            self.repository.unlock()
1009
 
        finally:
1010
1014
            self.control_files.unlock()
 
1015
        finally:
 
1016
            self.repository.unlock()
1011
1017
        
1012
1018
    def peek_lock_mode(self):
1013
1019
        if self.control_files._lock_count == 0: