# HG changeset patch # User Yuya Nishihara # Date 1442318428 -32400 # Node ID bc1f8a79b4e432ecd8b499e1c7f5184b9b3fb8f3 # Parent 3166bcc0c53840833e4223f123731fc420c0d3d3 localrepo: move closure of lock release to class It only captures "self", so it isn't necessary to be created dynamically. diff -r 3166bcc0c538 -r bc1f8a79b4e4 mercurial/localrepo.py --- a/mercurial/localrepo.py Wed Sep 16 22:30:36 2015 +0800 +++ b/mercurial/localrepo.py Tue Sep 15 21:00:28 2015 +0900 @@ -1198,6 +1198,13 @@ self.invalidate() self.invalidatedirstate() + def _refreshfilecachestats(self): + """Reload stats of cached files so that they are flagged as valid""" + for k, ce in self._filecache.items(): + if k == 'dirstate' or k not in self.__dict__: + continue + ce.refresh() + def _lock(self, vfs, lockname, wait, releasefn, acquirefn, desc): try: l = lockmod.lock(vfs, lockname, 0, releasefn, desc=desc) @@ -1240,13 +1247,7 @@ l.lock() return l - def unlock(): - for k, ce in self._filecache.items(): - if k == 'dirstate' or k not in self.__dict__: - continue - ce.refresh() - - l = self._lock(self.svfs, "lock", wait, unlock, + l = self._lock(self.svfs, "lock", wait, self._refreshfilecachestats, self.invalidate, _('repository %s') % self.origroot) self._lockref = weakref.ref(l) return l