Patchwork strip: use the 'writenewbundle' function to get bundle on disk

login
register
mail settings
Submitter Pierre-Yves David
Date May 25, 2017, 7:11 p.m.
Message ID <fe4d931431ab849db781.1495739477@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/20920/
State Accepted
Headers show

Comments

Pierre-Yves David - May 25, 2017, 7:11 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1494000942 -7200
#      Fri May 05 18:15:42 2017 +0200
# Node ID fe4d931431ab849db7814d162817ee9db7d4c84f
# Parent  548478efc46c6147e9c2781cf70477b3461b440d
# EXP-Topic bundle2.tagsfnodecache
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r fe4d931431ab
strip: use the 'writenewbundle' function to get bundle on disk

This will ensure the backup bundle use the best available logic (eg: includes
relevant caches so that we loose less of them on strip.)
via Mercurial-devel - May 27, 2017, 5:37 a.m.
On Thu, May 25, 2017 at 12:11 PM, Pierre-Yves David
<pierre-yves.david@ens-lyon.org> wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@octobus.net>
> # Date 1494000942 -7200
> #      Fri May 05 18:15:42 2017 +0200
> # Node ID fe4d931431ab849db7814d162817ee9db7d4c84f
> # Parent  548478efc46c6147e9c2781cf70477b3461b440d
> # EXP-Topic bundle2.tagsfnodecache
> # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
> #              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r fe4d931431ab
> strip: use the 'writenewbundle' function to get bundle on disk
>
> This will ensure the backup bundle use the best available logic (eg: includes
> relevant caches so that we loose less of them on strip.)

Queued thanks. This will hopefully be helpful towards adding support
for preserving phases across strip/unbundle as well.

Patch

diff --git a/mercurial/repair.py b/mercurial/repair.py
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -16,6 +16,7 @@  from .node import short
 from . import (
     bundle2,
     changegroup,
+    discovery,
     error,
     exchange,
     obsolete,
@@ -24,10 +25,7 @@  from . import (
 
 def _bundle(repo, bases, heads, node, suffix, compress=True):
     """create a bundle with the specified revisions as a backup"""
-    cgversion = changegroup.safeversion(repo)
 
-    cg = changegroup.changegroupsubset(repo, bases, heads, 'strip',
-                                       version=cgversion)
     backupdir = "strip-backup"
     vfs = repo.vfs
     if not vfs.isdir(backupdir):
@@ -39,6 +37,7 @@  def _bundle(repo, bases, heads, node, su
     totalhash = hashlib.sha1(''.join(allhashes)).hexdigest()
     name = "%s/%s-%s-%s.hg" % (backupdir, short(node), totalhash[:8], suffix)
 
+    cgversion = changegroup.safeversion(repo)
     comp = None
     if cgversion != '01':
         bundletype = "HG20"
@@ -48,8 +47,11 @@  def _bundle(repo, bases, heads, node, su
         bundletype = "HG10BZ"
     else:
         bundletype = "HG10UN"
-    return bundle2.writebundle(repo.ui, cg, name, bundletype, vfs,
-                                   compression=comp)
+
+    outgoing = discovery.outgoing(repo, missingroots=bases, missingheads=heads)
+    contentopts = {'cg.version': cgversion}
+    return bundle2.writenewbundle(repo.ui, repo, 'strip', name, bundletype,
+                                  outgoing, contentopts, vfs, compression=comp)
 
 def _collectfiles(repo, striprev):
     """find out the filelogs affected by the strip"""