diff hgext/evolve.py @ 1159:04bd66779a1f

obsup: hack extension to make in-place upgrading of obsolete markers easy I tried upgrading my obsstore by doing a local clone as suggested by Pierre-Yves and Sean, but that caused me to end up with a ton of unstable changes that should have been marked dead. In fact, as far as I can tell, most of the performance win of that upgrade came from the fact that only about 46% (46672 of 102285) of my markers were brought over with the copy-and-pull method.
author Augie Fackler <raf@durin42.com>
date Mon, 20 Oct 2014 22:16:24 -0400
parents 5951969400ce
children 6f08a8f6bb1d
line wrap: on
line diff
--- a/hgext/evolve.py	Tue Nov 11 15:48:02 2014 +0000
+++ b/hgext/evolve.py	Mon Oct 20 22:16:24 2014 -0400
@@ -2754,6 +2754,24 @@
     for chg, obs in _obsrelsethashtree(repo):
         ui.status('%s %s\n' % (node.hex(chg), node.hex(obs)))
 
+_bestformat = max(obsolete.formats.keys())
+
+@command(
+    'debugobsconvert',
+    [('', 'new-format', _bestformat, _('Destination format for markers.'))],
+    '')
+def debugobsconvert(ui, repo, new_format):
+    if new_format == repo.obsstore._version:
+        msg = _('New format is the same as the old format, not upgrading!')
+        raise util.Abort(msg)
+    f = repo.sopener('obsstore', 'wb', atomictemp=True)
+    markers = repo.obsstore._all
+    ui.write(_('Old store is version %d, will rewrite in verion %d\n') % (
+        repo.obsstore._version, new_format))
+    map(f.write, obsolete.encodemarkers(markers, True, new_format))
+    f.close()
+    ui.write(_('Done!\n'))
+
 
 @eh.wrapfunction(wireproto, 'capabilities')
 def capabilities(orig, repo, proto):