~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lock.py

  • Committer: Andrew Bennetts
  • Date: 2010-01-18 07:00:11 UTC
  • mto: (4973.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4975.
  • Revision ID: andrew.bennetts@canonical.com-20100118070011-zu374wvd0lcgai5a
Move news_merge plugin from contrib to bzrlib/plugins, change it to be enabled via a 'news_merge_files' config option, move more code out of the __init__ to minimise overhead, and add lots of docstrings, add NEWS entry.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
84
84
        return self.lock_url == other.lock_url and self.details == other.details
85
85
 
86
86
    def __repr__(self):
87
 
        return '%s(%s, %s)' % (self.__class__.__name__,
 
87
        return '%s(%s%s)' % (self.__class__.__name__,
88
88
                             self.lock_url, self.details)
89
89
 
90
90
 
91
 
class LogicalLockResult(object):
92
 
    """The result of a lock_read/lock_write/lock_tree_write call on lockables.
93
 
 
94
 
    :ivar unlock: A callable which will unlock the lock.
95
 
    """
96
 
 
97
 
    def __init__(self, unlock):
98
 
        self.unlock = unlock
99
 
 
100
 
    def __repr__(self):
101
 
        return "LogicalLockResult(%s)" % (self.unlock)
102
 
 
103
 
 
104
 
 
105
91
def cant_unlock_not_held(locked_object):
106
92
    """An attempt to unlock failed because the object was not locked.
107
93
 
214
200
 
215
201
            self._open(self.filename, 'rb+')
216
202
            # reserve a slot for this lock - even if the lockf call fails,
217
 
            # at this point unlock() will be called, because self.f is set.
 
203
            # at thisi point unlock() will be called, because self.f is set.
218
204
            # TODO: make this fully threadsafe, if we decide we care.
219
205
            _fcntl_WriteLock._open_locks.add(self.filename)
220
206
            try: