changeset 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 0f6c97421cd9
children 6f08a8f6bb1d
files hgext/evolve.py tests/test-obsconvert.t
diffstat 2 files changed, 52 insertions(+), 0 deletions(-) [+]
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):
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-obsconvert.t	Mon Oct 20 22:16:24 2014 -0400
@@ -0,0 +1,34 @@
+  $ cat >> $HGRCPATH <<EOF
+  > [extensions]
+  > rebase=
+  > EOF
+  $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext/evolve.py" >> $HGRCPATH
+  $ hg init alpha
+  $ cd alpha
+  $ echo foo > foo
+  $ hg addremove
+  adding foo
+  $ hg ci -m 'foo'
+  $ for x in 1 2 3 4 ; do
+  >   echo foo $x > foo
+  >   hg amend
+  > done
+
+Test conversion between obsolete marker formats
+  $ hg debugobsconvert --new-format 0
+  Old store is version 1, will rewrite in verion 0
+  Done!
+  $ hg debugobsconvert --new-format 0
+  abort: New format is the same as the old format, not upgrading!
+  [255]
+  $ hg debugobsconvert --new-format 1
+  Old store is version 0, will rewrite in verion 1
+  Done!
+
+Test that the default is some reasonably modern format (first downgrade)
+  $ hg debugobsconvert --new-format 0
+  Old store is version 1, will rewrite in verion 0
+  Done!
+  $ hg debugobsconvert
+  Old store is version 0, will rewrite in verion * (glob)
+  Done!