comparison mercurial/localrepo.py @ 8108:a26d33749bd8

made repo locks recursive and deprecate refcounting based lock releasing all locks should use the explicit lock.release mercurial.lock.lock.__del__ handles unwrapping recursive locks localrepo.lock/wlock are still using weakref in order to keep backward compatibiltiy to releasing locks via garbage collection by ensuring the release on __del__
author Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
date Wed, 22 Apr 2009 02:01:22 +0200
parents ecf7795479d5
children 496ae1ea4698
comparison
equal deleted inserted replaced
8107:0eeb4f0a5d21 8108:a26d33749bd8
681 if acquirefn: 681 if acquirefn:
682 acquirefn() 682 acquirefn()
683 return l 683 return l
684 684
685 def lock(self, wait=True): 685 def lock(self, wait=True):
686 if self._lockref and self._lockref(): 686 l = self._lockref and self._lockref()
687 return self._lockref() 687 if l is not None and l.held:
688 l.lock()
689 return l
688 690
689 l = self._lock(self.sjoin("lock"), wait, None, self.invalidate, 691 l = self._lock(self.sjoin("lock"), wait, None, self.invalidate,
690 _('repository %s') % self.origroot) 692 _('repository %s') % self.origroot)
691 self._lockref = weakref.ref(l) 693 self._lockref = weakref.ref(l)
692 return l 694 return l
693 695
694 def wlock(self, wait=True): 696 def wlock(self, wait=True):
695 if self._wlockref and self._wlockref(): 697 l = self._wlockref and self._wlockref()
696 return self._wlockref() 698 if l is not None and l.held:
699 l.lock()
700 return l
697 701
698 l = self._lock(self.join("wlock"), wait, self.dirstate.write, 702 l = self._lock(self.join("wlock"), wait, self.dirstate.write,
699 self.dirstate.invalidate, _('working directory of %s') % 703 self.dirstate.invalidate, _('working directory of %s') %
700 self.origroot) 704 self.origroot)
701 self._wlockref = weakref.ref(l) 705 self._wlockref = weakref.ref(l)