Patchwork [2,of,5,RFC] revlog: store fulltext when compressed delta is bigger than it

login
register
mail settings
Submitter Siddharth Agarwal
Date Nov. 12, 2014, 11:09 p.m.
Message ID <0b81a4a0fe70072919c1.1415833749@devbig136.prn2.facebook.com>
Download mbox | patch
Permalink /patch/6692/
State Accepted
Commit 6cc1f388ac805145600dc41fb045002d23cf53ca
Headers show

Comments

Siddharth Agarwal - Nov. 12, 2014, 11:09 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1415770872 28800
#      Tue Nov 11 21:41:12 2014 -0800
# Node ID 0b81a4a0fe70072919c1f3fd4b6cb6f9dbeb4e53
# Parent  900a9b80092255c0fed08016a69ec1ffbcca0a3f
revlog: store fulltext when compressed delta is bigger than it

This is a very silly case and not particularly likely to happen in the wild,
but it turns out we can hit it in a couple of places. As we tune the storage
parameters we're likely to hit more such cases.

The affected test cases all have smaller revlogs now.

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1254,7 +1254,7 @@ 
                                         cachedelta[1])
         else:
             textlen = len(text)
-        if (d is None or dist > textlen * 2 or
+        if (d is None or dist > textlen * 2 or l > textlen or
             (self._maxchainlen and chainlen > self._maxchainlen)):
             text = buildtext()
             data = self.compress(text)
diff --git a/tests/test-copy.t b/tests/test-copy.t
--- a/tests/test-copy.t
+++ b/tests/test-copy.t
@@ -184,7 +184,7 @@ 
      rev    offset  length  ..... linkrev nodeid       p1           p2 (re)
        0         0      69  .....       1 7711d36246cc 000000000000 000000000000 (re)
        1        69       6  .....       2 bdf70a2b8d03 7711d36246cc 000000000000 (re)
-       2        75      81  .....       3 b2558327ea8d 000000000000 000000000000 (re)
+       2        75      71  .....       3 b2558327ea8d 000000000000 000000000000 (re)
 should match
   $ hg debugindex foo
      rev    offset  length  ..... linkrev nodeid       p1           p2 (re)
diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t
--- a/tests/test-obsolete.t
+++ b/tests/test-obsolete.t
@@ -90,8 +90,8 @@ 
   # rev p1rev p2rev start   end deltastart base   p1   p2 rawsize totalsize compression heads chainlen
       0    -1    -1     0    59          0    0    0    0      58        58           0     1        0
       1     0    -1    59   118         59   59    0    0      58       116           0     1        0
-      2     1    -1   118   204         59   59   59    0      76       192           0     1        1
-      3     1    -1   204   271        204  204   59    0      66       258           0     2        0
+      2     1    -1   118   193        118  118   59    0      76       192           0     1        0
+      3     1    -1   193   260        193  193   59    0      66       258           0     2        0
   $ hg debugobsolete
   245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
 
diff --git a/tests/test-relink.t b/tests/test-relink.t
--- a/tests/test-relink.t
+++ b/tests/test-relink.t
@@ -87,7 +87,7 @@ 
   pruned down to 2 probably relinkable files
   relinking: data/a.i 1/2 files (50.00%)
   not linkable: data/dummy.i
-  relinked 1 files (1.37 KB reclaimed)
+  relinked 1 files (1.36 KB reclaimed)
   $ cd ..
 
 
diff --git a/tests/test-revlog-packentry.t b/tests/test-revlog-packentry.t
--- a/tests/test-revlog-packentry.t
+++ b/tests/test-revlog-packentry.t
@@ -18,6 +18,6 @@ 
   $ hg debugindex foo
      rev    offset  length  ..... linkrev nodeid       p1           p2 (re)
        0         0       0  .....       0 b80de5d13875 000000000000 000000000000 (re)
-       1         0      24  .....       1 0376abec49b8 000000000000 000000000000 (re)
+       1         0      13  .....       1 0376abec49b8 000000000000 000000000000 (re)
 
   $ cd ..