Mercurial > evolve
changeset 121:7280eede21ea
obsolete: improve locking when writing obsolete data
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Sat, 07 Jan 2012 11:26:48 +0100 |
parents | ba45bb2d35cb |
children | c75a73209f1e |
files | hgext/obsolete.py |
diffstat | 1 files changed, 9 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/obsolete.py Sat Jan 07 11:20:59 2012 +0100 +++ b/hgext/obsolete.py Sat Jan 07 11:26:48 2012 +0100 @@ -387,15 +387,19 @@ def _writeobsrels(self): """Write obsolete relation on disk""" # XXX handle lock - f = self.opener('obsolete-relations', 'w', atomictemp=True) + lock = self.wlock() try: - _obsserialise(self._obssubrels, f) + f = self.opener('obsolete-relations', 'w', atomictemp=True) try: - f.rename() - except AttributeError: # old version + _obsserialise(self._obssubrels, f) + try: + f.rename() + except AttributeError: # old version + f.close() + finally: f.close() finally: - f.close() + lock.release() ### local clone support