[Updated] D10889: revlog: factor the logic to determine the delta compression out

marmoute (Pierre-Yves David) phabricator at mercurial-scm.org
Mon Jun 21 15:16:36 UTC 2021


Closed by commit rHGc6844912c327: revlog: factor the logic to determine the delta compression out (authored by marmoute).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D10889?vs=28644&id=28660

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D10889/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D10889

AFFECTED FILES
  mercurial/revlog.py
  mercurial/revlogutils/deltas.py

CHANGE DETAILS

diff --git a/mercurial/revlogutils/deltas.py b/mercurial/revlogutils/deltas.py
--- a/mercurial/revlogutils/deltas.py
+++ b/mercurial/revlogutils/deltas.py
@@ -18,6 +18,9 @@
 from ..pycompat import getattr
 
 from .constants import (
+    COMP_MODE_DEFAULT,
+    COMP_MODE_INLINE,
+    COMP_MODE_PLAIN,
     REVIDX_ISCENSORED,
     REVIDX_RAWTEXT_CHANGING_FLAGS,
 )
@@ -1113,3 +1116,28 @@
         if deltainfo is None:
             deltainfo = self._fullsnapshotinfo(fh, revinfo)
         return deltainfo
+
+
+def delta_compression(default_compression_header, deltainfo):
+    """return (COMPRESSION_MODE, deltainfo)
+
+    used by revlog v2+ format to dispatch between PLAIN and DEFAULT
+    compression.
+    """
+    h, d = deltainfo.data
+    compression_mode = COMP_MODE_INLINE
+    if not h and not d:
+        # not data to store at all... declare them uncompressed
+        compression_mode = COMP_MODE_PLAIN
+    elif not h:
+        t = d[0:1]
+        if t == b'\0':
+            compression_mode = COMP_MODE_PLAIN
+        elif t == default_compression_header:
+            compression_mode = COMP_MODE_DEFAULT
+    elif h == b'u':
+        # we have a more efficient way to declare uncompressed
+        h = b''
+        compression_mode = COMP_MODE_PLAIN
+        deltainfo = drop_u_compression(deltainfo)
+    return compression_mode, deltainfo
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -2437,21 +2437,9 @@
 
         compression_mode = COMP_MODE_INLINE
         if self._docket is not None:
-            h, d = deltainfo.data
-            if not h and not d:
-                # not data to store at all... declare them uncompressed
-                compression_mode = COMP_MODE_PLAIN
-            elif not h:
-                t = d[0:1]
-                if t == b'\0':
-                    compression_mode = COMP_MODE_PLAIN
-                elif t == self._docket.default_compression_header:
-                    compression_mode = COMP_MODE_DEFAULT
-            elif h == b'u':
-                # we have a more efficient way to declare uncompressed
-                h = b''
-                compression_mode = COMP_MODE_PLAIN
-                deltainfo = deltautil.drop_u_compression(deltainfo)
+            default_comp = self._docket.default_compression_header
+            r = deltautil.delta_compression(default_comp, deltainfo)
+            compression_mode, deltainfo = r
 
         sidedata_compression_mode = COMP_MODE_INLINE
         if sidedata and self.hassidedata:



To: marmoute, indygreg, #hg-reviewers, Alphare
Cc: Alphare, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210621/c428a292/attachment-0002.html>


More information about the Mercurial-patches mailing list