# HG changeset patch # User Pierre-Yves David # Date 1325932008 -3600 # Node ID 7280eede21ea32c9e31e8fa31c76efed7bcf6886 # Parent ba45bb2d35cbaf57a42457c27963410201a53421 obsolete: improve locking when writing obsolete data diff -r ba45bb2d35cb -r 7280eede21ea hgext/obsolete.py --- 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