Mercurial > evolve
changeset 2748:723f5b505c48
debugobsconvert: take the lock when writing the obsstore file
We were upgrading the store unprotected.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sun, 16 Jul 2017 11:11:06 +0200 |
parents | 9fd6c8efda5b |
children | e1b7ea48e243 |
files | hgext3rd/evolve/__init__.py |
diffstat | 1 files changed, 18 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/__init__.py Fri Jul 14 08:08:32 2017 +0530 +++ b/hgext3rd/evolve/__init__.py Sun Jul 16 11:11:06 2017 +0200 @@ -2998,23 +2998,24 @@ if new_format == repo.obsstore._version: msg = _('New format is the same as the old format, not upgrading!') raise error.Abort(msg) - f = repo.svfs('obsstore', 'wb', atomictemp=True) - known = set() - markers = [] - for m in origmarkers: - # filter out invalid markers - if nullid in m[1]: - m = list(m) - m[1] = tuple(s for s in m[1] if s != nullid) - m = tuple(m) - if m in known: - continue - known.add(m) - markers.append(m) - ui.write(_('Old store is version %d, will rewrite in version %d\n') % ( - repo.obsstore._version, new_format)) - map(f.write, obsolete.encodemarkers(markers, True, new_format)) - f.close() + with repo.lock(): + f = repo.svfs('obsstore', 'wb', atomictemp=True) + known = set() + markers = [] + for m in origmarkers: + # filter out invalid markers + if nullid in m[1]: + m = list(m) + m[1] = tuple(s for s in m[1] if s != nullid) + m = tuple(m) + if m in known: + continue + known.add(m) + markers.append(m) + ui.write(_('Old store is version %d, will rewrite in version %d\n') % ( + repo.obsstore._version, new_format)) + map(f.write, obsolete.encodemarkers(markers, True, new_format)) + f.close() ui.write(_('Done!\n'))