Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 15583:926a06f7a353
lock: add mechanism to register post release callback
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Mon, 28 Nov 2011 15:05:26 +0100 |
parents | 1eefa4451c56 |
children | 9df9444e96ec |
comparison
equal
deleted
inserted
replaced
15581:d8fa35c28335 | 15583:926a06f7a353 |
---|---|
909 l = lock.lock(lockname, int(self.ui.config("ui", "timeout", "600")), | 909 l = lock.lock(lockname, int(self.ui.config("ui", "timeout", "600")), |
910 releasefn, desc=desc) | 910 releasefn, desc=desc) |
911 if acquirefn: | 911 if acquirefn: |
912 acquirefn() | 912 acquirefn() |
913 return l | 913 return l |
914 | |
915 def _postrelease(self, callback): | |
916 """add a callback to the current repository lock. | |
917 | |
918 The callback will be executed on lock release.""" | |
919 l = self._lockref and self._lockref() | |
920 assert l is not None | |
921 assert l.held | |
922 l.postreleasehooks.append(callback) | |
914 | 923 |
915 def lock(self, wait=True): | 924 def lock(self, wait=True): |
916 '''Lock the repository store (.hg/store) and return a weak reference | 925 '''Lock the repository store (.hg/store) and return a weak reference |
917 to the lock. Use this before modifying the store (e.g. committing or | 926 to the lock. Use this before modifying the store (e.g. committing or |
918 stripping). If you are opening a transaction, get a lock as well.)''' | 927 stripping). If you are opening a transaction, get a lock as well.)''' |