debugobsconvert: take the lock when writing the obsstore file
We were upgrading the store unprotected.
--- 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'))