Patchwork [STABLE] revlog: make sure we never use sparserevlog without general delta (issue6056)

login
register
mail settings
Submitter Boris Feld
Date Jan. 25, 2019, 8 p.m.
Message ID <c7661fdcaeac457aa5b8.1548446452@localhost.localdomain>
Download mbox | patch
Permalink /patch/38023/
State New
Headers show

Comments

Boris Feld - Jan. 25, 2019, 8 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1548372167 18000
#      Thu Jan 24 18:22:47 2019 -0500
# Branch stable
# Node ID c7661fdcaeac457aa5b8ae6b6a10b259713934b9
# Parent  26ee61c33dee366576a0f7266fea9834985e78ec
# EXP-Topic issue6056
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r c7661fdcaeac
revlog: make sure we never use sparserevlog without general delta (issue6056)

We are getting user report where the delta code tries to use `sparse-revlog`
logic on repository where `generaldelta` is disabled. This can't work so we
ensure the two booleans have a consistent value.

Creating this kind of repository is not expected to be possible and we weren't
able to create one for testing purpose. But if users run into this, we better
put stronger protection.
Yuya Nishihara - Jan. 28, 2019, 12:20 p.m.
On Fri, 25 Jan 2019 15:00:52 -0500, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1548372167 18000
> #      Thu Jan 24 18:22:47 2019 -0500
> # Branch stable
> # Node ID c7661fdcaeac457aa5b8ae6b6a10b259713934b9
> # Parent  26ee61c33dee366576a0f7266fea9834985e78ec
> # EXP-Topic issue6056
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r c7661fdcaeac
> revlog: make sure we never use sparserevlog without general delta (issue6056)
> 
> We are getting user report where the delta code tries to use `sparse-revlog`
> logic on repository where `generaldelta` is disabled. This can't work so we
> ensure the two booleans have a consistent value.
> 
> Creating this kind of repository is not expected to be possible and we weren't
> able to create one for testing purpose. But if users run into this, we better
> put stronger protection.

Mathias, do you have any idea how the broken repository could be created?

> --- a/mercurial/revlog.py
> +++ b/mercurial/revlog.py
> @@ -497,6 +497,9 @@ class revlog(object):
>          else:
>              raise error.RevlogError(_('unknown version (%d) in revlog %s') %
>                                      (fmt, self.indexfile))
> +        # sparse-revlog can't be on without general-delta (issue6056)
> +        if not self._generaldelta:
> +            self._sparserevlog = False

Maybe this can be handled at localrepo.ensurerequirements*() or
esolverevlogstorevfsoptions(), where ui is available so we can add
some debug/warning messages.

And, UnboundLocalError is most likely a coding error. If that's due to
contract violation, it would be better to raise a proper exception instead.

  if sparse and not gdelta:
      raise error.ProgrammingError(...)  # or StorageError?
Mathias De Maré - Jan. 29, 2019, 8:25 a.m.
On Mon, Jan 28, 2019 at 1:21 PM Yuya Nishihara <yuya@tcha.org> wrote:

> On Fri, 25 Jan 2019 15:00:52 -0500, Boris Feld wrote:
> > # HG changeset patch
> > # User Boris Feld <boris.feld@octobus.net>
> > # Date 1548372167 18000
> > #      Thu Jan 24 18:22:47 2019 -0500
> > # Branch stable
> > # Node ID c7661fdcaeac457aa5b8ae6b6a10b259713934b9
> > # Parent  26ee61c33dee366576a0f7266fea9834985e78ec
> > # EXP-Topic issue6056
> > # Available At https://bitbucket.org/octobus/mercurial-devel/
> > #              hg pull https://bitbucket.org/octobus/mercurial-devel/
> -r c7661fdcaeac
> > revlog: make sure we never use sparserevlog without general delta
> (issue6056)
> >
> > We are getting user report where the delta code tries to use
> `sparse-revlog`
> > logic on repository where `generaldelta` is disabled. This can't work so
> we
> > ensure the two booleans have a consistent value.
> >
> > Creating this kind of repository is not expected to be possible and we
> weren't
> > able to create one for testing purpose. But if users run into this, we
> better
> > put stronger protection.
>
> Mathias, do you have any idea how the broken repository could be created?
>

I think the issue might be related to our use of streaming clonebundles and
a mismatch between some repositories on our server.
For one specific repository, I see on the server that .hg/requires contains
"revlogv1 store fncache dotencode".
On the client that cloned (and cannot commit), the requires contains:
"dotencode fncache generaldelta revlogv1 sparserevlog store"

I did an 'hg debugupgraderepo' on the server and regenerated the
clonebundle. Cloning again and committing on the client then works fine.

Greetings,
Mathias
Yuya Nishihara - Jan. 29, 2019, 11:41 a.m.
On Mon, 28 Jan 2019 21:20:07 +0900, Yuya Nishihara wrote:
> On Fri, 25 Jan 2019 15:00:52 -0500, Boris Feld wrote:
> > # HG changeset patch
> > # User Boris Feld <boris.feld@octobus.net>
> > # Date 1548372167 18000
> > #      Thu Jan 24 18:22:47 2019 -0500
> > # Branch stable
> > # Node ID c7661fdcaeac457aa5b8ae6b6a10b259713934b9
> > # Parent  26ee61c33dee366576a0f7266fea9834985e78ec
> > # EXP-Topic issue6056
> > # Available At https://bitbucket.org/octobus/mercurial-devel/
> > #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r c7661fdcaeac
> > revlog: make sure we never use sparserevlog without general delta (issue6056)
> > 
> > We are getting user report where the delta code tries to use `sparse-revlog`
> > logic on repository where `generaldelta` is disabled. This can't work so we
> > ensure the two booleans have a consistent value.
> > 
> > Creating this kind of repository is not expected to be possible and we weren't
> > able to create one for testing purpose. But if users run into this, we better
> > put stronger protection.

> > --- a/mercurial/revlog.py
> > +++ b/mercurial/revlog.py
> > @@ -497,6 +497,9 @@ class revlog(object):
> >          else:
> >              raise error.RevlogError(_('unknown version (%d) in revlog %s') %
> >                                      (fmt, self.indexfile))
> > +        # sparse-revlog can't be on without general-delta (issue6056)
> > +        if not self._generaldelta:
> > +            self._sparserevlog = False
> 
> Maybe this can be handled at localrepo.ensurerequirements*() or
> esolverevlogstorevfsoptions(), where ui is available so we can add
> some debug/warning messages.

Okay, it doesn't work since generaldelta is a revlog flag, whereas sparserevlog
is a global requirement. I don't know if sparserevlog should be a revlog flag
or not, but anyway only thing we can do here is to turn off the sparse, as your
patch does.

Can you add some tests with crafted repo?

Also, I noticed format.sparse-revlog isn't documented. Since it's incompatible
with older versions, it needs some doc.
Yuya Nishihara - Jan. 29, 2019, 12:11 p.m.
On Tue, 29 Jan 2019 09:25:34 +0100, Mathias De Maré wrote:
> On Mon, Jan 28, 2019 at 1:21 PM Yuya Nishihara <yuya@tcha.org> wrote:
> > On Fri, 25 Jan 2019 15:00:52 -0500, Boris Feld wrote:
> > > # HG changeset patch
> > > # User Boris Feld <boris.feld@octobus.net>
> > > # Date 1548372167 18000
> > > #      Thu Jan 24 18:22:47 2019 -0500
> > > # Branch stable
> > > # Node ID c7661fdcaeac457aa5b8ae6b6a10b259713934b9
> > > # Parent  26ee61c33dee366576a0f7266fea9834985e78ec
> > > # EXP-Topic issue6056
> > > # Available At https://bitbucket.org/octobus/mercurial-devel/
> > > #              hg pull https://bitbucket.org/octobus/mercurial-devel/
> > -r c7661fdcaeac
> > > revlog: make sure we never use sparserevlog without general delta
> > (issue6056)
> > >
> > > We are getting user report where the delta code tries to use
> > `sparse-revlog`
> > > logic on repository where `generaldelta` is disabled. This can't work so
> > we
> > > ensure the two booleans have a consistent value.
> > >
> > > Creating this kind of repository is not expected to be possible and we
> > weren't
> > > able to create one for testing purpose. But if users run into this, we
> > better
> > > put stronger protection.
> >
> > Mathias, do you have any idea how the broken repository could be created?
> >
> 
> I think the issue might be related to our use of streaming clonebundles and
> a mismatch between some repositories on our server.
> For one specific repository, I see on the server that .hg/requires contains
> "revlogv1 store fncache dotencode".
> On the client that cloned (and cannot commit), the requires contains:
> "dotencode fncache generaldelta revlogv1 sparserevlog store"

That makes sense, thanks.

The problem could be reproduced by adding --config format.usegeneraldelta=0
--config format.sparse-revlog=0 to test-clonebundles.t.
Gregory Szorc - Jan. 29, 2019, 6:41 p.m.
On Tue, Jan 29, 2019 at 3:44 AM Yuya Nishihara <yuya@tcha.org> wrote:

> On Mon, 28 Jan 2019 21:20:07 +0900, Yuya Nishihara wrote:
> > On Fri, 25 Jan 2019 15:00:52 -0500, Boris Feld wrote:
> > > # HG changeset patch
> > > # User Boris Feld <boris.feld@octobus.net>
> > > # Date 1548372167 18000
> > > #      Thu Jan 24 18:22:47 2019 -0500
> > > # Branch stable
> > > # Node ID c7661fdcaeac457aa5b8ae6b6a10b259713934b9
> > > # Parent  26ee61c33dee366576a0f7266fea9834985e78ec
> > > # EXP-Topic issue6056
> > > # Available At https://bitbucket.org/octobus/mercurial-devel/
> > > #              hg pull https://bitbucket.org/octobus/mercurial-devel/
> -r c7661fdcaeac
> > > revlog: make sure we never use sparserevlog without general delta
> (issue6056)
> > >
> > > We are getting user report where the delta code tries to use
> `sparse-revlog`
> > > logic on repository where `generaldelta` is disabled. This can't work
> so we
> > > ensure the two booleans have a consistent value.
> > >
> > > Creating this kind of repository is not expected to be possible and we
> weren't
> > > able to create one for testing purpose. But if users run into this, we
> better
> > > put stronger protection.
>
> > > --- a/mercurial/revlog.py
> > > +++ b/mercurial/revlog.py
> > > @@ -497,6 +497,9 @@ class revlog(object):
> > >          else:
> > >              raise error.RevlogError(_('unknown version (%d) in revlog
> %s') %
> > >                                      (fmt, self.indexfile))
> > > +        # sparse-revlog can't be on without general-delta (issue6056)
> > > +        if not self._generaldelta:
> > > +            self._sparserevlog = False
> >
> > Maybe this can be handled at localrepo.ensurerequirements*() or
> > esolverevlogstorevfsoptions(), where ui is available so we can add
> > some debug/warning messages.
>
> Okay, it doesn't work since generaldelta is a revlog flag, whereas
> sparserevlog
> is a global requirement. I don't know if sparserevlog should be a revlog
> flag
> or not, but anyway only thing we can do here is to turn off the sparse, as
> your
> patch does.
>

Sparse should have a revlog flag in addition to a repo requirement. My
understanding is we already shipped sparse support in 4.8. This means we
can't introduce a revlog flag (and corresponding repo requirement) without
a BC change. I started a series to introduce revlog version 2 (mainly to
support zstd compression in revlogs). We can do things more properly in
revlog version 2. But I fear the lack of a sparse revlog flag will just
have to be an historical wart since we've already shipped it.


>
> Can you add some tests with crafted repo?
>
> Also, I noticed format.sparse-revlog isn't documented. Since it's
> incompatible
> with older versions, it needs some doc.
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
Boris Feld - Jan. 30, 2019, 5:21 p.m.
On 29/01/2019 13:41, Gregory Szorc wrote:
> On Tue, Jan 29, 2019 at 3:44 AM Yuya Nishihara <yuya@tcha.org
> <mailto:yuya@tcha.org>> wrote:
>
>     On Mon, 28 Jan 2019 21:20:07 +0900, Yuya Nishihara wrote:
>     > On Fri, 25 Jan 2019 15:00:52 -0500, Boris Feld wrote:
>     > > # HG changeset patch
>     > > # User Boris Feld <boris.feld@octobus.net
>     <mailto:boris.feld@octobus.net>>
>     > > # Date 1548372167 18000
>     > > #      Thu Jan 24 18:22:47 2019 -0500
>     > > # Branch stable
>     > > # Node ID c7661fdcaeac457aa5b8ae6b6a10b259713934b9
>     > > # Parent  26ee61c33dee366576a0f7266fea9834985e78ec
>     > > # EXP-Topic issue6056
>     > > # Available At https://bitbucket.org/octobus/mercurial-devel/
>     > > #              hg pull
>     https://bitbucket.org/octobus/mercurial-devel/ -r c7661fdcaeac
>     > > revlog: make sure we never use sparserevlog without general
>     delta (issue6056)
>     > >
>     > > We are getting user report where the delta code tries to use
>     `sparse-revlog`
>     > > logic on repository where `generaldelta` is disabled. This
>     can't work so we
>     > > ensure the two booleans have a consistent value.
>     > >
>     > > Creating this kind of repository is not expected to be
>     possible and we weren't
>     > > able to create one for testing purpose. But if users run into
>     this, we better
>     > > put stronger protection.
>
>     > > --- a/mercurial/revlog.py
>     > > +++ b/mercurial/revlog.py
>     > > @@ -497,6 +497,9 @@ class revlog(object):
>     > >          else:
>     > >              raise error.RevlogError(_('unknown version (%d)
>     in revlog %s') %
>     > >                                      (fmt, self.indexfile))
>     > > +        # sparse-revlog can't be on without general-delta
>     (issue6056)
>     > > +        if not self._generaldelta:
>     > > +            self._sparserevlog = False
>     >
>     > Maybe this can be handled at localrepo.ensurerequirements*() or
>     > esolverevlogstorevfsoptions(), where ui is available so we can add
>     > some debug/warning messages.
>
>     Okay, it doesn't work since generaldelta is a revlog flag, whereas
>     sparserevlog
>     is a global requirement. I don't know if sparserevlog should be a
>     revlog flag
>     or not, but anyway only thing we can do here is to turn off the
>     sparse, as your
>     patch does.
>
>
> Sparse should have a revlog flag in addition to a repo requirement. My
> understanding is we already shipped sparse support in 4.8.
Support is shipped since 4.7.
> This means we can't introduce a revlog flag (and corresponding repo
> requirement) without a BC change. I started a series to introduce
> revlog version 2 (mainly to support zstd compression in revlogs). We
> can do things more properly in revlog version 2. But I fear the lack
> of a sparse revlog flag will just have to be an historical wart since
> we've already shipped it.
>  
>
>
>     Can you add some tests with crafted repo?
>
>     Also, I noticed format.sparse-revlog isn't documented. Since it's
>     incompatible
>     with older versions, it needs some doc.
>     _______________________________________________
>     Mercurial-devel mailing list
>     Mercurial-devel@mercurial-scm.org
>     <mailto:Mercurial-devel@mercurial-scm.org>
>     https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Boris Feld - Jan. 30, 2019, 7:18 p.m.
On 29/01/2019 07:11, Yuya Nishihara wrote:
> On Tue, 29 Jan 2019 09:25:34 +0100, Mathias De Maré wrote:
>> On Mon, Jan 28, 2019 at 1:21 PM Yuya Nishihara <yuya@tcha.org> wrote:
>>> On Fri, 25 Jan 2019 15:00:52 -0500, Boris Feld wrote:
>>>> # HG changeset patch
>>>> # User Boris Feld <boris.feld@octobus.net>
>>>> # Date 1548372167 18000
>>>> #      Thu Jan 24 18:22:47 2019 -0500
>>>> # Branch stable
>>>> # Node ID c7661fdcaeac457aa5b8ae6b6a10b259713934b9
>>>> # Parent  26ee61c33dee366576a0f7266fea9834985e78ec
>>>> # EXP-Topic issue6056
>>>> # Available At https://bitbucket.org/octobus/mercurial-devel/
>>>> #              hg pull https://bitbucket.org/octobus/mercurial-devel/
>>> -r c7661fdcaeac
>>>> revlog: make sure we never use sparserevlog without general delta
>>> (issue6056)
>>>> We are getting user report where the delta code tries to use
>>> `sparse-revlog`
>>>> logic on repository where `generaldelta` is disabled. This can't work so
>>> we
>>>> ensure the two booleans have a consistent value.
>>>>
>>>> Creating this kind of repository is not expected to be possible and we
>>> weren't
>>>> able to create one for testing purpose. But if users run into this, we
>>> better
>>>> put stronger protection.
>>> Mathias, do you have any idea how the broken repository could be created?
>>>
>> I think the issue might be related to our use of streaming clonebundles and
>> a mismatch between some repositories on our server.
>> For one specific repository, I see on the server that .hg/requires contains
>> "revlogv1 store fncache dotencode".
>> On the client that cloned (and cannot commit), the requires contains:
>> "dotencode fncache generaldelta revlogv1 sparserevlog store"
> That makes sense, thanks.
>
> The problem could be reproduced by adding --config format.usegeneraldelta=0
> --config format.sparse-revlog=0 to test-clonebundles.t.
Where are you adding this? We could not reproduce on our side.
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Yuya Nishihara - Jan. 30, 2019, 10:43 p.m.
On Wed, 30 Jan 2019 14:18:29 -0500, Boris FELD wrote:
> On 29/01/2019 07:11, Yuya Nishihara wrote:
> > On Tue, 29 Jan 2019 09:25:34 +0100, Mathias De Maré wrote:
> >> On Mon, Jan 28, 2019 at 1:21 PM Yuya Nishihara <yuya@tcha.org> wrote:
> >>> On Fri, 25 Jan 2019 15:00:52 -0500, Boris Feld wrote:
> >>>> # HG changeset patch
> >>>> # User Boris Feld <boris.feld@octobus.net>
> >>>> # Date 1548372167 18000
> >>>> #      Thu Jan 24 18:22:47 2019 -0500
> >>>> # Branch stable
> >>>> # Node ID c7661fdcaeac457aa5b8ae6b6a10b259713934b9
> >>>> # Parent  26ee61c33dee366576a0f7266fea9834985e78ec
> >>>> # EXP-Topic issue6056
> >>>> # Available At https://bitbucket.org/octobus/mercurial-devel/
> >>>> #              hg pull https://bitbucket.org/octobus/mercurial-devel/
> >>> -r c7661fdcaeac
> >>>> revlog: make sure we never use sparserevlog without general delta
> >>> (issue6056)
> >>>> We are getting user report where the delta code tries to use
> >>> `sparse-revlog`
> >>>> logic on repository where `generaldelta` is disabled. This can't work so
> >>> we
> >>>> ensure the two booleans have a consistent value.
> >>>>
> >>>> Creating this kind of repository is not expected to be possible and we
> >>> weren't
> >>>> able to create one for testing purpose. But if users run into this, we
> >>> better
> >>>> put stronger protection.
> >>> Mathias, do you have any idea how the broken repository could be created?
> >>>
> >> I think the issue might be related to our use of streaming clonebundles and
> >> a mismatch between some repositories on our server.
> >> For one specific repository, I see on the server that .hg/requires contains
> >> "revlogv1 store fncache dotencode".
> >> On the client that cloned (and cannot commit), the requires contains:
> >> "dotencode fncache generaldelta revlogv1 sparserevlog store"
> > That makes sense, thanks.
> >
> > The problem could be reproduced by adding --config format.usegeneraldelta=0
> > --config format.sparse-revlog=0 to test-clonebundles.t.
> Where are you adding this? We could not reproduce on our side.

Added it to "hg init server", and some repository mutation to clones.
Yuya Nishihara - Jan. 31, 2019, 12:01 p.m.
On Tue, 29 Jan 2019 10:41:17 -0800, Gregory Szorc wrote:
> On Tue, Jan 29, 2019 at 3:44 AM Yuya Nishihara <yuya@tcha.org> wrote:
> > is a global requirement. I don't know if sparserevlog should be a revlog
> > flag
> > or not, but anyway only thing we can do here is to turn off the sparse, as
> > your
> > patch does.
> >
> 
> Sparse should have a revlog flag in addition to a repo requirement. My
> understanding is we already shipped sparse support in 4.8. This means we
> can't introduce a revlog flag (and corresponding repo requirement) without
> a BC change. I started a series to introduce revlog version 2 (mainly to
> support zstd compression in revlogs). We can do things more properly in
> revlog version 2. But I fear the lack of a sparse revlog flag will just
> have to be an historical wart since we've already shipped it.

Maybe we should document the wart in revlog.py so we won't make the same
kind of mistakes in future?
Boris Feld - Jan. 31, 2019, 3:12 p.m.
On 30/01/2019 17:43, Yuya Nishihara wrote:
> On Wed, 30 Jan 2019 14:18:29 -0500, Boris FELD wrote:
>> On 29/01/2019 07:11, Yuya Nishihara wrote:
>>> On Tue, 29 Jan 2019 09:25:34 +0100, Mathias De Maré wrote:
>>>> On Mon, Jan 28, 2019 at 1:21 PM Yuya Nishihara <yuya@tcha.org> wrote:
>>>>> On Fri, 25 Jan 2019 15:00:52 -0500, Boris Feld wrote:
>>>>>> # HG changeset patch
>>>>>> # User Boris Feld <boris.feld@octobus.net>
>>>>>> # Date 1548372167 18000
>>>>>> #      Thu Jan 24 18:22:47 2019 -0500
>>>>>> # Branch stable
>>>>>> # Node ID c7661fdcaeac457aa5b8ae6b6a10b259713934b9
>>>>>> # Parent  26ee61c33dee366576a0f7266fea9834985e78ec
>>>>>> # EXP-Topic issue6056
>>>>>> # Available At https://bitbucket.org/octobus/mercurial-devel/
>>>>>> #              hg pull https://bitbucket.org/octobus/mercurial-devel/
>>>>> -r c7661fdcaeac
>>>>>> revlog: make sure we never use sparserevlog without general delta
>>>>> (issue6056)
>>>>>> We are getting user report where the delta code tries to use
>>>>> `sparse-revlog`
>>>>>> logic on repository where `generaldelta` is disabled. This can't work so
>>>>> we
>>>>>> ensure the two booleans have a consistent value.
>>>>>>
>>>>>> Creating this kind of repository is not expected to be possible and we
>>>>> weren't
>>>>>> able to create one for testing purpose. But if users run into this, we
>>>>> better
>>>>>> put stronger protection.
>>>>> Mathias, do you have any idea how the broken repository could be created?
>>>>>
>>>> I think the issue might be related to our use of streaming clonebundles and
>>>> a mismatch between some repositories on our server.
>>>> For one specific repository, I see on the server that .hg/requires contains
>>>> "revlogv1 store fncache dotencode".
>>>> On the client that cloned (and cannot commit), the requires contains:
>>>> "dotencode fncache generaldelta revlogv1 sparserevlog store"
>>> That makes sense, thanks.
>>>
>>> The problem could be reproduced by adding --config format.usegeneraldelta=0
>>> --config format.sparse-revlog=0 to test-clonebundles.t.
>> Where are you adding this? We could not reproduce on our side.
> Added it to "hg init server", and some repository mutation to clones.
Do you have an exact patch to share? Adding it to `init` only was not
enough.
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -497,6 +497,9 @@  class revlog(object):
         else:
             raise error.RevlogError(_('unknown version (%d) in revlog %s') %
                                     (fmt, self.indexfile))
+        # sparse-revlog can't be on without general-delta (issue6056)
+        if not self._generaldelta:
+            self._sparserevlog = False
 
         self._storedeltachains = True