Rev 4114: (mbp) SSHSmartClientStreamMedium repr and better LockContention in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Wed Mar 11 10:22:05 GMT 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4114
revision-id: pqm at pqm.ubuntu.com-20090311102200-heffmfrrstw2fovy
parent: pqm at pqm.ubuntu.com-20090311082542-mgvtmiodx227pin4
parent: mbp at sourcefrog.net-20090311071030-vk7p00y42nldr4j7
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2009-03-11 10:22:00 +0000
message:
(mbp) SSHSmartClientStreamMedium repr and better LockContention
message
modified:
bzrlib/errors.py errors.py-20050309040759-20512168c4e14fbd
bzrlib/lock.py lock.py-20050527050856-ec090bb51bc03349
bzrlib/smart/medium.py medium.py-20061103051856-rgu2huy59fkz902q-1
------------------------------------------------------------
revno: 4100.1.5
revision-id: mbp at sourcefrog.net-20090311071030-vk7p00y42nldr4j7
parent: mbp at sourcefrog.net-20090311062654-xe3rp86l6npg2m9q
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: trivial
timestamp: Wed 2009-03-11 17:10:30 +1000
message:
Fix crash in SSHSmartClientStreamMedium repr.
The super init method uses the object's repr so some variables must be
saved before calling it.
modified:
bzrlib/smart/medium.py medium.py-20061103051856-rgu2huy59fkz902q-1
------------------------------------------------------------
revno: 4100.1.4
revision-id: mbp at sourcefrog.net-20090311062654-xe3rp86l6npg2m9q
parent: mbp at sourcefrog.net-20090311052357-jyjgg8cx7tveprei
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: trivial
timestamp: Wed 2009-03-11 16:26:54 +1000
message:
LockContention on OS locks now includes the filename
modified:
bzrlib/errors.py errors.py-20050309040759-20512168c4e14fbd
bzrlib/lock.py lock.py-20050527050856-ec090bb51bc03349
=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py 2009-03-10 23:39:48 +0000
+++ b/bzrlib/errors.py 2009-03-11 10:22:00 +0000
@@ -1003,14 +1003,15 @@
class LockContention(LockError):
- _fmt = 'Could not acquire lock "%(lock)s"'
+ _fmt = 'Could not acquire lock "%(lock)s": %(message)s'
# TODO: show full url for lock, combining the transport and relative
# bits?
internal_error = False
- def __init__(self, lock):
+ def __init__(self, lock, message=''):
self.lock = lock
+ self.message = message
class LockBroken(LockError):
=== modified file 'bzrlib/lock.py'
--- a/bzrlib/lock.py 2008-10-01 05:40:45 +0000
+++ b/bzrlib/lock.py 2009-03-11 06:26:54 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005, 2006, 2007, 2008 Canonical Ltd
+# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -185,7 +185,7 @@
self.unlock()
# we should be more precise about whats a locking
# error and whats a random-other error
- raise errors.LockContention(e)
+ raise errors.LockContention(self.filename, e)
def unlock(self):
_fcntl_WriteLock._open_locks.remove(self.filename)
@@ -209,7 +209,7 @@
except IOError, e:
# we should be more precise about whats a locking
# error and whats a random-other error
- raise errors.LockContention(e)
+ raise errors.LockContention(self.filename, e)
def unlock(self):
count = _fcntl_ReadLock._open_locks[self.filename]
@@ -277,7 +277,7 @@
fcntl.lockf(new_f, fcntl.LOCK_EX | fcntl.LOCK_NB)
except IOError, e:
# TODO: Raise a more specific error based on the type of error
- raise errors.LockContention(e)
+ raise errors.LockContention(self.filename, e)
_fcntl_WriteLock._open_locks.add(self.filename)
self.f = new_f
@@ -322,7 +322,7 @@
raise
except Exception, e:
self._clear_f()
- raise errors.LockContention(e)
+ raise errors.LockContention(filename, e)
def unlock(self):
overlapped = pywintypes.OVERLAPPED()
@@ -330,7 +330,7 @@
win32file.UnlockFileEx(self.hfile, 0, 0x7fff0000, overlapped)
self._clear_f()
except Exception, e:
- raise errors.LockContention(e)
+ raise errors.LockContention(self.filename, e)
class _w32c_ReadLock(_w32c_FileLock):
@@ -439,8 +439,8 @@
last_err = _GetLastError()
if last_err in (ERROR_LOCK_VIOLATION,):
raise errors.LockContention(filename)
- raise errors.LockContention('Unknown locking error: %s'
- % (last_err,))
+ raise errors.LockContention(filename,
+ 'Unknown locking error: %s' % (last_err,))
def unlock(self):
overlapped = OVERLAPPED()
@@ -454,8 +454,8 @@
if result == 0:
self._clear_f()
last_err = _GetLastError()
- raise errors.LockContention('Unknown unlocking error: %s'
- % (last_err,))
+ raise errors.LockContention(self.filename,
+ 'Unknown unlocking error: %s' % (last_err,))
class _ctypes_ReadLock(_ctypes_FileLock):
=== modified file 'bzrlib/smart/medium.py'
--- a/bzrlib/smart/medium.py 2009-03-11 06:25:14 +0000
+++ b/bzrlib/smart/medium.py 2009-03-11 10:22:00 +0000
@@ -727,12 +727,15 @@
:param vendor: An optional override for the ssh vendor to use. See
bzrlib.transport.ssh for details on ssh vendors.
"""
- SmartClientStreamMedium.__init__(self, base)
self._connected = False
self._host = host
self._password = password
self._port = port
self._username = username
+ # SmartClientStreamMedium stores the repr of this object in its
+ # _DebugCounter so we have to store all the values used in our repr
+ # method before calling the super init.
+ SmartClientStreamMedium.__init__(self, base)
self._read_from = None
self._ssh_connection = None
self._vendor = vendor
More information about the bazaar-commits
mailing list