comparison mercurial/localrepo.py @ 24821:57f1dbc99631 stable

afterlock: add the callback to the top level lock (issue4608) If 'wlock' is taken, we should add 'afterlock' callback to the 'wlock' instead. Otherwise, running post transaction hook after 'lock' is release but 'wlock' is still taken lead to a deadlock (eg: 'hg update' during a hook). This situation is much more common since: 5dc5cd7abbf5 push: acquire local 'wlock' if "pushback" is expected (BC) (issue4596)
author Pierre-Yves David <pierre-yves.david@fb.com>
date Mon, 20 Apr 2015 15:27:55 +0200
parents d99d7e3f5cda
children 0325c0da05df
comparison
equal deleted inserted replaced
24820:6a6b69d9e539 24821:57f1dbc99631
1192 if acquirefn: 1192 if acquirefn:
1193 acquirefn() 1193 acquirefn()
1194 return l 1194 return l
1195 1195
1196 def _afterlock(self, callback): 1196 def _afterlock(self, callback):
1197 """add a callback to the current repository lock. 1197 """add a callback to be run when the repository is fully unlocked
1198 1198
1199 The callback will be executed on lock release.""" 1199 The callback will be executed when the outermost lock is released
1200 l = self._lockref and self._lockref() 1200 (with wlock being higher level than 'lock')."""
1201 if l: 1201 for ref in (self._wlockref, self._lockref):
1202 l.postrelease.append(callback) 1202 l = ref and ref()
1203 else: 1203 if l and l.held:
1204 l.postrelease.append(callback)
1205 break
1206 else: # no lock have been found.
1204 callback() 1207 callback()
1205 1208
1206 def lock(self, wait=True): 1209 def lock(self, wait=True):
1207 '''Lock the repository store (.hg/store) and return a weak reference 1210 '''Lock the repository store (.hg/store) and return a weak reference
1208 to the lock. Use this before modifying the store (e.g. committing or 1211 to the lock. Use this before modifying the store (e.g. committing or