~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lock.py

  • Committer: v.ladeuil+lp at free
  • Date: 2007-05-15 17:40:32 UTC
  • mto: (2485.8.44 bzr.connection.sharing)
  • mto: This revision was merged to the branch mainline in revision 2646.
  • Revision ID: v.ladeuil+lp@free.fr-20070515174032-qzdkangpv29l9e7g
Add a test that check that init connect only once. It fails.

* __init__.py:
(test_suite): Register the new test class.

* test_init.py: 
(InstrumentedTransport): A transport that can track connections.
(TransportHooks): Transport specific hooks.
(TestInit): Iniit command behavior tests.

* ftp.py:
(FtpTransport.__init__): Mark place that need fixing regarding
transport connection sharing

* builtins.py:
(cmd_init.run): Mark places that need fixing regarding transport
connection sharing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
    )
45
45
 
46
46
 
47
 
class _OSLock(object):
 
47
class _base_Lock(object):
48
48
 
49
49
    def __init__(self):
50
50
        self.f = None
109
109
    lock_EX = fcntl.LOCK_EX
110
110
 
111
111
 
112
 
    class _fcntl_FileLock(_OSLock):
 
112
    class _fcntl_FileLock(_base_Lock):
113
113
 
114
114
        def _unlock(self):
115
115
            fcntl.lockf(self.f, fcntl.LOCK_UN)
196
196
            return True, wlock
197
197
 
198
198
 
199
 
    class _fcntl_TemporaryWriteLock(_OSLock):
 
199
    class _fcntl_TemporaryWriteLock(_base_Lock):
200
200
        """A token used when grabbing a temporary_write_lock.
201
201
 
202
202
        Call restore_read_lock() when you are done with the write lock.
258
258
    LOCK_NB = win32con.LOCKFILE_FAIL_IMMEDIATELY
259
259
 
260
260
 
261
 
    class _w32c_FileLock(_OSLock):
 
261
    class _w32c_FileLock(_base_Lock):
262
262
 
263
263
        def _lock(self, filename, openmode, lockmode):
264
264
            self._open(filename, openmode)
374
374
                    ('hEvent', ctypes.c_void_p), # HANDLE
375
375
                   ]
376
376
 
377
 
    class _ctypes_FileLock(_OSLock):
 
377
    class _ctypes_FileLock(_base_Lock):
378
378
 
379
379
        def _lock(self, filename, openmode, lockmode):
380
380
            self._open(filename, openmode)