lock: update the docstring with order information
authorPierre-Yves David <pierre-yves.david@fb.com>
Wed, 15 Apr 2015 01:20:48 -0400
changeset 24746 e0c810d0ab69
parent 24745 bc34b286781f
child 24747 bef8b17443a3
lock: update the docstring with order information Lock must be acquired in a specific order to avoid dead-lock. This was documented on the wiki, but having this information in the docstring is also useful.
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Sun Apr 12 13:28:35 2015 -0400
+++ b/mercurial/localrepo.py	Wed Apr 15 01:20:48 2015 -0400
@@ -1183,7 +1183,10 @@
     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.)'''
+        stripping). If you are opening a transaction, get a lock as well.)
+
+        If both 'lock' and 'wlock' must be acquired, ensure you always acquires
+        'wlock' first to avoid a dead-lock hazard.'''
         l = self._lockref and self._lockref()
         if l is not None and l.held:
             l.lock()
@@ -1203,7 +1206,11 @@
     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.'''
+
+        Use this before modifying files in .hg.
+
+        If both 'lock' and 'wlock' must be acquired, ensure you always acquires
+        'wlock' first to avoid a dead-lock hazard.'''
         l = self._wlockref and self._wlockref()
         if l is not None and l.held:
             l.lock()