Patchwork [STABLE] debugrevlog: improve handling of empty manifests/changelogs

login
register
mail settings
Submitter timeless
Date Jan. 29, 2016, 4:38 p.m.
Message ID <CAAKMeYh+QuqkKgP6MJnYDeJD-H84pu0gm2XZDKJjAjTnRZEUHQ@mail.gmail.com>
Download mbox | patch
Permalink /patch/12905/
State Superseded
Headers show

Comments

timeless - Jan. 29, 2016, 4:38 p.m.
> Why checking numerator?

If it's 0, then I'm happy saying the value is 0. If it's not zero,
then I don't want to decide how to handle it. I.e. from my perspective
0/x should be treated as 0, people can understand that. 1/0 otoh
should be Inf, and that's too hard to reason through. If we manage to
hit that case, I'd like someone else to solve it.


Removing the require is correct (and I'll do it if I can resend
something useful).

> You can make an empty commit by "--config ui.allowemptycommit=True" or
> "hg branch foo && hg ci".


@@ -13,48 +11,23 @@
   $ hg debugrevlog -m
   abort: repository manifest is empty
   [255]
-  $ hg pull "$TESTDIR/bundles/issue5062.hg" -r 0
-  pulling from *issue5062.hg (glob)
-  adding changesets
-  adding manifests
-  adding file changes
-  added 1 changesets with 0 changes to 0 files
-  (run 'hg update' to get a working copy)
+  $ hg commit --config ui.allowemptycommit=True -m 'empty'
+  $ hg debugrevlog -m
+  abort: repository manifest is empty
+  [255]
+
+  $ echo a > a
+  $ hg ci -Am adda
+  adding a
   $ hg debugrevlog -m
   format : 1
   flags  : inline, generaldelta

-  revisions     : 1
-      merges    : 0 ( 0.00%)
-      normal    : 1 (100.00%)
-  revisions     : 1
-      full      : 1 (100.00%)
-      deltas    : 0 ( 0.00%)
-  revision size : 0
-      full      : 0 (100.00%)
-      deltas    : 0 (100.00%)
-
-  avg chain length  : 0
-  max chain length  : 0
-  compression ratio : 1
-
-  uncompressed data size (min/max/avg) : 0 / 0 / 0
-  full revision size (min/max/avg)     : 0 / 0 / 0
-  delta size (min/max/avg)             : 0 / 0 / 0
-
-  $ echo a > a
-  $ hg ci -Am adda
-  adding a
-  created new head
-  $ hg debugrevlog -m
-  format : 1
-  flags  : inline, generaldelta
-
-  revisions     :  2
+  revisions     :  1
       merges    :  0 ( 0.00%)
-      normal    :  2 (100.00%)
-  revisions     :  2
-      full      :  2 (100.00%)
+      normal    :  1 (100.00%)
+  revisions     :  1
+      full      :  1 (100.00%)
       deltas    :  0 ( 0.00%)
   revision size : 44
       full      : 44 (100.00%)

This doesn't seem to match what I was expecting at all. Apparently an
empty commit isn't considered a revision (?!).

@@ -64,8 +37,8 @@
   max chain length  : 0
   compression ratio : 0

-  uncompressed data size (min/max/avg) : 0 / 43 / 21
-  full revision size (min/max/avg)     : 0 / 44 / 22
+  uncompressed data size (min/max/avg) : 43 / 43 / 43
+  full revision size (min/max/avg)     : 44 / 44 / 44
   delta size (min/max/avg)             : 0 / 0 / 0

 Test debugindex, with and without the --debug flag
@@ -86,32 +59,16 @@

   $ hg debugdeltachain -m
       rev  chain# chainlen     prev   delta       size    rawsize
chainsize     ratio   lindist extradist extraratio
-        0       1        1       -1    base          0          0
     0   0.00000         0         0    0.00000
-        1       2        1       -1    base         44         43
    44   1.02326        44         0    0.00000
+        0       1        1       -1    base         44         43
    44   1.02326        44         0    0.00000

   $ hg debugdeltachain -m -T '{rev} {chainid} {chainlen}\n'
   0 1 1
-  1 2 1

   $ hg debugdeltachain -m -Tjson
   [
    {
     "chainid": 1,
     "chainlen": 1,
-    "chainratio": 0.0,
-    "chainsize": 0,
-    "compsize": 0,
-    "deltatype": "base",
-    "extradist": 0,
-    "extraratio": 0.0,
-    "lindist": 0,
-    "prevrev": -1,
-    "rev": 0,
-    "uncompsize": 0
-   },
-   {
-    "chainid": 2,
-    "chainlen": 1,
     "chainratio": 1.02325581395,
     "chainsize": 44,
     "compsize": 44,
@@ -120,7 +77,7 @@
     "extraratio": 0.0,
     "lindist": 44,
     "prevrev": -1,
-    "rev": 1,
+    "rev": 0,
     "uncompsize": 43
    }
   ]
Yuya Nishihara - Jan. 31, 2016, 7:55 a.m.
On Fri, 29 Jan 2016 11:38:04 -0500, timeless wrote:
> > Why checking numerator?
> 
> If it's 0, then I'm happy saying the value is 0. If it's not zero,
> then I don't want to decide how to handle it. I.e. from my perspective
> 0/x should be treated as 0, people can understand that. 1/0 otoh
> should be Inf, and that's too hard to reason through. If we manage to
> hit that case, I'd like someone else to solve it.

I don't see much difference between 0/0=0 and x/0=0. Both are generally
undefined. Because this patch is the workaround for ZeroDivisionError, it
doesn't make sense for me to handle 0/x specially.

FYI, "gzip -l" shows "0.0%" for x/0, but in "xz -l", it is "---".

> > You can make an empty commit by "--config ui.allowemptycommit=True" or
> > "hg branch foo && hg ci".
>
> This doesn't seem to match what I was expecting at all. Apparently an
> empty commit isn't considered a revision (?!).

You're right. Empty commit doesn't make a new entry in 00manifest.i.

https://selenic.com/repo/hg/rev/301725c3df9a

Patch

diff -r 8b7958075035 tests/test-debugcommands.t
--- a/tests/test-debugcommands.t    Mon Jan 25 20:40:38 2016 +0000
+++ b/tests/test-debugcommands.t    Fri Jan 29 16:24:05 2016 +0000
@@ -1,5 +1,3 @@ 
-#require test-repo
-
   $ cat << EOF >> $HGRCPATH
   > [format]
   > usegeneraldelta=yes