localrepo: document the locking scheme a little better

- localrepo: document lock(), wlock() methods
- lock: add class docstring
This commit is contained in:
Greg Ward 2009-08-05 14:42:57 +02:00
parent 136a5f6615
commit 80075c97bf
2 changed files with 16 additions and 1 deletions

View File

@ -651,6 +651,9 @@ class localrepository(repo.repository):
return l
def lock(self, wait=True):
'''Lock the repository store (.hg/store) and return a weak reference
to the lock. Use this before modifying the store (e.g. committing or
stripping). If you are opening a transaction, get a lock as well.)'''
l = self._lockref and self._lockref()
if l is not None and l.held:
l.lock()
@ -662,6 +665,9 @@ class localrepository(repo.repository):
return l
def wlock(self, wait=True):
'''Lock the non-store parts of the repository (everything under
.hg except .hg/store) and return a weak reference to the lock.
Use this before modifying files in .hg.'''
l = self._wlockref and self._wlockref()
if l is not None and l.held:
l.lock()

View File

@ -1,4 +1,4 @@
# lock.py - simple locking scheme for mercurial
# lock.py - simple advisory locking scheme for mercurial
#
# Copyright 2005, 2006 Matt Mackall <mpm@selenic.com>
#
@ -10,6 +10,15 @@ import errno, os, socket, time
import warnings
class lock(object):
'''An advisory lock held by one process to control access to a set
of files. Non-cooperating processes or incorrectly written scripts
can ignore Mercurial's locking scheme and stomp all over the
repository, so don't do that.
Typically used via localrepository.lock() to lock the repository
store (.hg/store/) or localrepository.wlock() to lock everything
else under .hg/.'''
# lock is symlink on platforms that support it, file on others.
# symlink is used because create of directory entry and contents