changeset 1171:d14537d7dca9

merge with stable
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 20 Nov 2014 15:34:34 -0800
parents 4697f23e0ede (diff) 2187f7c88ff6 (current diff)
children 8d28bb4fc127
files hgext/evolve.py
diffstat 2 files changed, 59 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/evolve.py	Thu Nov 20 22:05:29 2014 +0100
+++ b/hgext/evolve.py	Thu Nov 20 15:34:34 2014 -0800
@@ -2762,6 +2762,31 @@
     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)
+    origmarkers = repo.obsstore._all
+    known = set()
+    markers = []
+    for m in markers:
+        if m in known:
+            continue
+        know.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'))
+
 
 @eh.wrapfunction(wireproto, 'capabilities')
 def capabilities(orig, repo, proto):
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-obsconvert.t	Thu Nov 20 15:34:34 2014 -0800
@@ -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 version 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 version 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 version 0
+  Done!
+  $ hg debugobsconvert
+  Old store is version 0, will rewrite in version 1
+  Done!