localrepo: document the locking scheme a little better
- localrepo: document lock(), wlock() methods
- lock: add class docstring
--- a/mercurial/localrepo.py Wed Aug 05 17:20:47 2009 +0200
+++ b/mercurial/localrepo.py Wed Aug 05 14:42:57 2009 +0200
@@ -651,6 +651,9 @@
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 @@
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()
--- a/mercurial/lock.py Wed Aug 05 17:20:47 2009 +0200
+++ b/mercurial/lock.py Wed Aug 05 14:42:57 2009 +0200
@@ -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 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