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

login
register
mail settings
Submitter Pierre-Yves David
Date Oct. 20, 2015, 2:36 p.m.
Message ID <8ede0199ba8248090263.1445351785@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/11191/
State Superseded
Commit 38dcb85f9370bf2b647b4e728cb9488a960d7d22
Headers show

Comments

Pierre-Yves David - Oct. 20, 2015, 2:36 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@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.
Matt Mackall - Oct. 20, 2015, 7:16 p.m.
On Tue, 2015-10-20 at 16:36 +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@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

This line makes check-commit upset every time.

> histedit: properly apply bundle2 backups

These are queued for default, thanks.
-- 
Mathematics is the supreme nostalgia of our time.

Patch

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):