Patchwork [4,of,4] changegroup: allow to force delta to be against p1

login
register
mail settings
Submitter Boris Feld
Date Oct. 16, 2018, 8:33 a.m.
Message ID <153b15991f547ab7aa05.1539678813@localhost.localdomain>
Download mbox | patch
Permalink /patch/36034/
State New
Headers show

Comments

Boris Feld - Oct. 16, 2018, 8:33 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1539123662 -7200
#      Wed Oct 10 00:21:02 2018 +0200
# Node ID 153b15991f547ab7aa05e06999a8aa6ee56b7fc3
# Parent  c835d3020e536e8ef368223d628b9e0c6d0c8251
# EXP-Topic slim-bundle
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 153b15991f54
changegroup: allow to force delta to be against p1

This new developer option is useful to general more "generic" bundle. Without
this option, a bundle generated from the repository use deltas similar to the
one stored in the specific repository it was generated from. This makes
performance testing a bit tricky.

Using deltas similar to the final result means all delta stored in the bundle
can be applied to the target repository without any further processing (except
for the rare case of a full snapshot). The application of such bundles
(almost) never exercises the (slower) path of searching for a new valid delta.
This result in unrealistic and too favorable timing and profile.

Instead, we introduce an option to make sure all revisions are stored as a
delta against p1. It might not be the best generation option, but it
guarantees that the content will be "generic", not favoring a specific target.

Patch

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -704,6 +704,8 @@  def deltagroup(repo, store, nodes, ischa
     deltamode = storageutil.DELTAMODE_STD
     if forcedeltaparentprev:
         deltamode = storageutil.DELTAMODE_PREV
+    elif repo.ui.configbool('devel', 'bundle.delta-p1'):
+        deltamode = storageutil.DELTAMODE_PREV
 
     revisions = store.emitrevisions(
         nodes,
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -329,6 +329,9 @@  coreconfigitem('devel', 'all-warnings',
 coreconfigitem('devel', 'bundle2.debug',
     default=False,
 )
+coreconfigitem('devel', 'bundle.delta-p1',
+    default=False,
+)
 coreconfigitem('devel', 'cache-vfs',
     default=None,
 )
diff --git a/mercurial/utils/storageutil.py b/mercurial/utils/storageutil.py
--- a/mercurial/utils/storageutil.py
+++ b/mercurial/utils/storageutil.py
@@ -268,6 +268,7 @@  def resolvestripinfo(minlinkrev, tiprev,
 DELTAMODE_STD = 'default'
 DELTAMODE_PREV = 'previous'
 DELTAMODE_FULL = 'fulltext'
+DELTAMODE_P1 = 'p1'
 
 def emitrevisions(store, nodes, nodesorder, resultcls, deltaparentfn=None,
                   candeltafn=None, rawsizefn=None, revdifffn=None, flagsfn=None,
@@ -374,6 +375,9 @@  def emitrevisions(store, nodes, nodesord
         # We're instructed to send fulltext. Honor that.
         elif deltamode == DELTAMODE_FULL:
             baserev = nullrev
+        # We're instructed to use p1. Honor that
+        elif deltamode == DELTAMODE_P1:
+            baserev = p1rev
 
         # There is a delta in storage. We try to use that because it
         # amounts to effectively copying data from storage and is
diff --git a/tests/test-bundle.t b/tests/test-bundle.t
--- a/tests/test-bundle.t
+++ b/tests/test-bundle.t
@@ -900,3 +900,8 @@  the warning shouldn't be emitted
   $ hg update -R ../update2bundled.hg -r 0
   0 files updated, 0 files merged, 2 files removed, 0 files unresolved
 #endif
+
+Test the option that create slim bundle
+
+  $ hg bundle -a --config devel.bundle.delta-p1=yes ./slim.hg
+  3 changesets found