Commit Graph

28 Commits

Author SHA1 Message Date
Benoit Boissinot
8b1492e457 lock: the correct way to do a trylock() is to use a timeout of 0 2009-11-16 11:55:29 +01:00
Benoit Boissinot
16abbe4cd8 lock: catch specific exceptions 2009-10-31 18:10:52 +01:00
Benoit Boissinot
d2dcc4c950 lock: use '==' instead of 'is' for integer equality ('is' may not work) 2009-10-31 17:07:12 +01:00
Greg Ward
80075c97bf localrepo: document the locking scheme a little better
- localrepo: document lock(), wlock() methods
- lock: add class docstring
2009-08-05 14:42:57 +02:00
Simon Heimberg
09ac1e6c92 separate import lines from mercurial and general python modules 2009-04-28 17:40:46 +02:00
Martin Geisler
750183bdad updated license to be explicit about GPL version 2 2009-04-26 01:08:54 +02:00
Ronny Pfannschmidt
23e91269e5 add a deprecation warning for gc based lock releasing 2009-04-22 02:01:22 +02:00
Ronny Pfannschmidt
f55e3eb9a7 made repo locks recursive and deprecate refcounting based lock releasing
all locks should use the explicit lock.release

mercurial.lock.lock.__del__ handles unwrapping recursive locks

localrepo.lock/wlock are still using weakref in order to keep backward
compatibiltiy to releasing locks via garbage collection
by ensuring the release on __del__
2009-04-22 02:01:22 +02:00
Matt Mackall
76c90d50e6 error: move lock errors
rename LockException to LockError
2009-01-12 11:09:14 -06:00
Thomas Arendsen Hein
def3b1c2ba Use format string for lockname again (was changed by cb157328a155) 2007-07-21 10:39:42 +02:00
Bryan O'Sullivan
cd2a579d50 lock.py: cache hostname, but not pid, in case we fork 2007-07-19 15:13:48 -07:00
Matt Mackall
f17a4e1934 Replace demandload with new demandimport 2006-12-13 13:27:09 -06:00
Thomas Arendsen Hein
6046bbb871 Don't step into an endless loop when lock file is empty. 2006-11-20 19:36:28 +01:00
Vadim Gelfer
dc377b58c1 update copyrights. 2006-08-12 12:30:02 -07:00
Benoit Boissinot
7dd019b60b use __contains__, index or split instead of str.find
str.find return -1 when the substring is not found, -1 evaluate
to True and is a valid index, which can lead to bugs.
Using alternatives when possible makes the code clearer and less
prone to bugs. (and __contains__ is faster in microbenchmarks)
2006-07-09 01:30:30 +02:00
Vadim Gelfer
959e983875 fix backtrace printed when cannot get lock.
change lock error handling code so exceptions have useful info and
exception handling in one place.

add test case for when cannot get lock.
2006-03-28 09:01:07 -08:00
Vadim Gelfer
61a7953729 change lock format to let us detect and break stale locks.
old style: symlink to pid
new style: symlink to hostname:pid

if lock code finds new-style lock, it breaks lock if locking pid is on
same machine and pid is not alive.

otherwise, lock is left alone.  this makes locking code safe with
old-style locks and with locks on other machines.

new code makes server part of mercurial more robust in case machine
crashes, power fails, or crazy user does kill -9.
2006-03-10 08:31:31 -08:00
Vadim Gelfer
ecbcdd0c46 make lock module use demandload. 2006-03-05 01:37:28 -08:00
Benoit Boissinot
25acc6be22 add a timeout when a lock is held (default 1024 sec)
- change the wait keyword from lock.lock to timeout,
  a negative timeout of means "wait forever"
- refactor the two lock functions from localrepo.py
- make them use the timeout (default 1024, can be changed
  with ui.timeout in the config file
- update the doc
2006-02-21 23:21:15 +01:00
Benoit Boissinot
6f064de857 Raise a different exception when the lock is not available
When the filesystem is read-only or if we have some other
error, there is no need to wait.
Raise a lock.LockUnavailable exception.
2006-02-20 01:09:40 +01:00
Eric Hopper
dd6718fc31 Convert all classes to new-style classes by deriving them from object. 2005-11-18 22:48:47 -08:00
Benoit Boissinot
956119e446 add a releasefn keyword to lock.lock
releasefn is a function that will be executed when the lock is released
2005-11-11 15:34:09 -08:00
benoit.boissinot@ens-lyon.fr
95b97f01ed pep-0008 cleanup
- Don't use spaces around the '=' sign when used to indicate a
      keyword argument or a default parameter value.
2005-08-26 13:06:58 +02:00
Thomas Arendsen Hein
e78588e43a Make makelock and readlock work on filesystems without symlink support.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Make makelock and readlock work on filesystems without symlink support.
This way you can have a repository on a fat partiton, e.g. a USB stick.

manifest hash: cea2c120ef2b25a50c5d98b59648f773feefe470
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFC1t5yW7P1GVgWeRoRAsKjAJ9BFcn/EqBK/dmJ4BY1pPIZIbDDJACghN3p
VCQS6CJ72MHpzhOOsnOpHzE=
=laDT
-----END PGP SIGNATURE-----
2005-07-14 22:51:47 +01:00
mpm@selenic.com
0fb5db6915 Whitespace cleanups
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Whitespace cleanups

manifest hash: ac954bc3a4f034c12638a259ecd65841f5b63c5c
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)

iD8DBQFCwuubywK+sNU5EO8RAluIAJ98XQpNdZUpSmYKgDmrMRlbL76ZzQCfes0t
rknNUN/PhtyA4bzL646dOz4=
=UyCE
-----END PGP SIGNATURE-----
2005-06-29 10:42:35 -08:00
mpm@selenic.com
a58fa92f5c Fix troubles with clone and exception handling
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Fix troubles with clone and exception handling

Clone deletes its directory on failure

This was deleting the lockfile out from under the lock object before
it got destroyed

This patch shuts lock up and makes the cleanup code for clone a little
cleaner.

manifest hash: f666fddcf6f3a905020a091f5e9fd2cb5d806cdd
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)

iD8DBQFCwSGOywK+sNU5EO8RAkx2AKCIxPczl9YWnuUM+bMQnpVr8kv6uQCeNWld
SUxSB99PGJHhq1LWFaSJJNw=
=Frk/
-----END PGP SIGNATURE-----
2005-06-28 02:08:14 -08:00
mpm@selenic.com
e0a4782d31 [PATCH] Enables lock work under the other 'OS'
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[PATCH] Enables lock work under the other 'OS'
From: K Thananchayan <thananck@yahoo.com>

os.symlink is not supported under Windows. This patch
introduces util.mklockf, util.getlowner that use
regular files under Winodws but symlink under unix.

tweaked by mpm:
 - changed function names
 - fixed to work on UNIX

manifest hash: 6f650a78a3b203dcad2f861582500b6b4036599a
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)

iD8DBQFCuN5sywK+sNU5EO8RAva8AJ9L9z/JHRAJS1bix48ZzSpn9ZUyPwCffhmg
UfLSFBmd5tPDDi3mgsrdDEA=
=ZYS9
-----END PGP SIGNATURE-----
2005-06-21 19:43:40 -08:00
mpm@selenic.com
0058e326b8 Simply repository locking
This is a first pass at implementing repo locking. Next up, journal
recovery and undo.
2005-05-26 08:53:04 -08:00