[PATCH 09 of 14 FIX-bundle2] histedit: properly apply bundle2 backups

Pierre-Yves David pierre-yves.david at ens-lyon.org
Tue Oct 20 09:36:25 CDT 2015


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1445303243 -7200
#      Tue Oct 20 03:07:23 2015 +0200
# Node ID 8ede0199ba8248090263b1cf870c1468431726bd
# Parent  122054fdc36932f18ae6af7d66d908718e88a0d1
# EXP-Topic generaldelta
# Available At http://hg.netv6.net/marmoute-wip/mercurial/
#              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r 8ede0199ba82
histedit: properly apply bundle2 backups

If the histedit fails we restore a backup. We make sure this backup bundle can
be in bundle2 format as general delta will requires.

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -158,10 +158,11 @@ except ImportError:
     import pickle
 import errno
 import os
 import sys
 
+from mercurial import bundle2
 from mercurial import cmdutil
 from mercurial import discovery
 from mercurial import error
 from mercurial import copies
 from mercurial import context
@@ -820,11 +821,17 @@ def _histedit(ui, repo, state, *freeargs
             # Recover our old commits if necessary
             if not state.topmost in repo and state.backupfile:
                 backupfile = repo.join(state.backupfile)
                 f = hg.openpath(ui, backupfile)
                 gen = exchange.readbundle(ui, f, backupfile)
-                gen.apply(repo, 'histedit', 'bundle:' + backupfile)
+                if not isinstance(gen, bundle2.unbundle20):
+                    gen.apply(repo, 'histedit', 'bundle:' + backupfile)
+                if isinstance(gen, bundle2.unbundle20):
+                    bundle2.applybundle(repo, gen,
+                                        repo.currenttransaction(),
+                                        source='histedit',
+                                        url='bundle:' + backupfile)
                 os.remove(backupfile)
 
             # check whether we should update away
             if repo.unfiltered().revs('parents() and (%n  or %ln::)',
                                     state.parentctxnode, leafs | tmpnodes):


More information about the Mercurial-devel mailing list