~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lockdir.py

  • Committer: Andrew Bennetts
  • Date: 2009-07-27 05:35:00 UTC
  • mfrom: (4570 +trunk)
  • mto: (4634.6.29 2.0)
  • mto: This revision was merged to the branch mainline in revision 4680.
  • Revision ID: andrew.bennetts@canonical.com-20090727053500-q76zsn2dx33jhmj5
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""On-disk mutex protecting a resource
18
18
 
125
125
        ResourceBusy,
126
126
        TransportError,
127
127
        )
128
 
from bzrlib.hooks import Hooks
129
128
from bzrlib.trace import mutter, note
130
129
from bzrlib.osutils import format_delta, rand_chars, get_host_name
131
130
import bzrlib.ui
294
293
            self._fake_read_lock = False
295
294
            return
296
295
        if not self._lock_held:
297
 
            raise LockNotHeld(self)
 
296
            return lock.cant_unlock_not_held(self)
298
297
        if self._locked_via_token:
299
298
            self._locked_via_token = False
300
299
            self._lock_held = False
326
325
            self._trace("... unlock succeeded after %dms",
327
326
                    (time.time() - start_time) * 1000)
328
327
            result = lock.LockResult(self.transport.abspath(self.path),
329
 
                old_nonce)
 
328
                                     old_nonce)
330
329
            for hook in self.hooks['lock_released']:
331
330
                hook(result)
332
331
 
380
379
            raise LockBreakMismatch(self, broken_info, dead_holder_info)
381
380
        self.transport.delete(broken_info_path)
382
381
        self.transport.rmdir(tmpname)
 
382
        result = lock.LockResult(self.transport.abspath(self.path),
 
383
                                 current_info.get('nonce'))
 
384
        for hook in self.hooks['lock_broken']:
 
385
            hook(result)
383
386
 
384
387
    def _check_not_locked(self):
385
388
        """If the lock is held by this instance, raise an error."""