deltas: add a `debug.revlog.debug-delta` config option enable output
authorPierre-Yves David <pierre-yves.david@octobus.net>
Thu, 19 May 2022 23:39:42 +0100
changeset 49227 2bcf5e14bb7e
parent 49226 e6b7c6fbeb48
child 49228 b909dd35d9ab
deltas: add a `debug.revlog.debug-delta` config option enable output This provide a way to enable the code introduced in the previous changeset. This will provide a large amount of output when applying a bundle with details about each delta "computation".
mercurial/configitems.py
mercurial/localrepo.py
mercurial/revlog.py
tests/test-bundle.t
--- a/mercurial/configitems.py	Thu May 19 23:39:23 2022 +0100
+++ b/mercurial/configitems.py	Thu May 19 23:39:42 2022 +0100
@@ -584,6 +584,11 @@
     default=b'',
 )
 coreconfigitem(
+    b'debug',
+    b'revlog.debug-delta',
+    default=False,
+)
+coreconfigitem(
     b'defaults',
     b'.*',
     default=None,
--- a/mercurial/localrepo.py	Thu May 19 23:39:23 2022 +0100
+++ b/mercurial/localrepo.py	Thu May 19 23:39:42 2022 +0100
@@ -1070,6 +1070,7 @@
         b'storage', b'revlog.optimize-delta-parent-choice'
     )
     options[b'deltabothparents'] = deltabothparents
+    options[b'debug-delta'] = ui.configbool(b'debug', b'revlog.debug-delta')
 
     issue6528 = ui.configbool(b'storage', b'revlog.issue6528.fix-incoming')
     options[b'issue6528.fix-incoming'] = issue6528
--- a/mercurial/revlog.py	Thu May 19 23:39:23 2022 +0100
+++ b/mercurial/revlog.py	Thu May 19 23:39:42 2022 +0100
@@ -346,6 +346,7 @@
         self._chunkcachesize = 65536
         self._maxchainlen = None
         self._deltabothparents = True
+        self._debug_delta = False
         self.index = None
         self._docket = None
         self._nodemap_docket = None
@@ -423,6 +424,8 @@
         self._lazydeltabase = False
         if self._lazydelta:
             self._lazydeltabase = bool(opts.get(b'lazydeltabase', False))
+        if b'debug-delta' in opts:
+            self._debug_delta = opts[b'debug-delta']
         if b'compengine' in opts:
             self._compengine = opts[b'compengine']
         if b'zlib.level' in opts:
@@ -2426,7 +2429,12 @@
             textlen = len(rawtext)
 
         if deltacomputer is None:
-            deltacomputer = deltautil.deltacomputer(self)
+            write_debug = None
+            if self._debug_delta:
+                write_debug = transaction._report
+            deltacomputer = deltautil.deltacomputer(
+                self, write_debug=write_debug
+            )
 
         revinfo = revlogutils.revisioninfo(
             node,
@@ -2639,7 +2647,13 @@
         empty = True
         try:
             with self._writing(transaction):
-                deltacomputer = deltautil.deltacomputer(self)
+                write_debug = None
+                if self._debug_delta:
+                    write_debug = transaction._report
+                deltacomputer = deltautil.deltacomputer(
+                    self,
+                    write_debug=write_debug,
+                )
                 # loop through our set of deltas
                 for data in deltas:
                     (
@@ -3015,7 +3029,13 @@
         sidedata_helpers,
     ):
         """perform the core duty of `revlog.clone` after parameter processing"""
-        deltacomputer = deltautil.deltacomputer(destrevlog)
+        write_debug = None
+        if self._debug_delta:
+            write_debug = tr._report
+        deltacomputer = deltautil.deltacomputer(
+            destrevlog,
+            write_debug=write_debug,
+        )
         index = self.index
         for rev in self:
             entry = index[rev]
--- a/tests/test-bundle.t	Thu May 19 23:39:23 2022 +0100
+++ b/tests/test-bundle.t	Thu May 19 23:39:42 2022 +0100
@@ -1038,3 +1038,28 @@
 Test the option that create and no-delta's bundle
   $ hg bundle -a --config devel.bundle.delta=full ./full.hg
   3 changesets found
+
+Test the debug output when applying delta
+-----------------------------------------
+
+  $ hg init foo
+  $ hg -R foo unbundle ./slim.hg \
+  > --config debug.revlog.debug-delta=yes \
+  > --config storage.revlog.reuse-external-delta=no \
+  > --config storage.revlog.reuse-external-delta-parent=no
+  adding changesets
+  DBG-DELTAS: CHANGELOG:   rev=0: search-rounds=0 try-count=0 - delta-type=full   snap-depth=0 - p1-chain-length=-1 p2-chain-length=-1 - duration=* (glob)
+  DBG-DELTAS: CHANGELOG:   rev=1: search-rounds=0 try-count=0 - delta-type=full   snap-depth=0 - p1-chain-length=0 p2-chain-length=-1 - duration=* (glob)
+  DBG-DELTAS: CHANGELOG:   rev=2: search-rounds=0 try-count=0 - delta-type=full   snap-depth=0 - p1-chain-length=0 p2-chain-length=-1 - duration=* (glob)
+  adding manifests
+  DBG-DELTAS: MANIFESTLOG: rev=0: search-rounds=0 try-count=0 - delta-type=full   snap-depth=0 - p1-chain-length=-1 p2-chain-length=-1 - duration=* (glob)
+  DBG-DELTAS: MANIFESTLOG: rev=1: search-rounds=1 try-count=1 - delta-type=delta  snap-depth=0 - p1-chain-length=0 p2-chain-length=-1 - duration=* (glob)
+  DBG-DELTAS: MANIFESTLOG: rev=2: search-rounds=1 try-count=1 - delta-type=delta  snap-depth=0 - p1-chain-length=1 p2-chain-length=-1 - duration=* (glob)
+  adding file changes
+  DBG-DELTAS: FILELOG:a:   rev=0: search-rounds=0 try-count=0 - delta-type=full   snap-depth=0 - p1-chain-length=-1 p2-chain-length=-1 - duration=* (glob)
+  DBG-DELTAS: FILELOG:b:   rev=0: search-rounds=0 try-count=0 - delta-type=full   snap-depth=0 - p1-chain-length=-1 p2-chain-length=-1 - duration=* (glob)
+  DBG-DELTAS: FILELOG:c:   rev=0: search-rounds=0 try-count=0 - delta-type=full   snap-depth=0 - p1-chain-length=-1 p2-chain-length=-1 - duration=* (glob)
+  added 3 changesets with 3 changes to 3 files
+  new changesets 4fe08cd4693e:4652c276ac4f (3 drafts)
+  (run 'hg update' to get a working copy)
+