Patchwork revlog: add exception when linkrev == nullrev

login
register
mail settings
Submitter Durham Goode
Date June 18, 2013, 2:47 a.m.
Message ID <275d78d339cc7d954952.1371523623@dev350.prn1.facebook.com>
Download mbox | patch
Permalink /patch/1731/
State Accepted, archived
Delegated to: Augie Fackler
Headers show

Comments

Durham Goode - June 18, 2013, 2:47 a.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1371523440 25200
#      Mon Jun 17 19:44:00 2013 -0700
# Node ID 275d78d339cc7d954952f9a17ecaad4d098073ff
# Parent  2d03c8da7d981a101c5f4d8dd5f9a55eb778033f
revlog: add exception when linkrev == nullrev

When we deployed the latest crew mercurial to our users, a few of them
had issues where a filelog would have an entry with a -1 linkrev. This
caused operations like rebase and amend to create a bundle containing the
entire repository, which took a long time.

I don't know what the issue is, but adding this check should prevent repos
from getting in this state, and should help us pinpoint the issue next time
it happens.
Augie Fackler - June 18, 2013, 12:28 p.m.
LGTM

(In an airport, too lazy to queue right now.)

On Jun 17, 2013, at 10:47 PM, Durham Goode <durham@fb.com> wrote:

> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1371523440 25200
> #      Mon Jun 17 19:44:00 2013 -0700
> # Node ID 275d78d339cc7d954952f9a17ecaad4d098073ff
> # Parent  2d03c8da7d981a101c5f4d8dd5f9a55eb778033f
> revlog: add exception when linkrev == nullrev
> 
> When we deployed the latest crew mercurial to our users, a few of them
> had issues where a filelog would have an entry with a -1 linkrev. This
> caused operations like rebase and amend to create a bundle containing the
> entire repository, which took a long time.
> 
> I don't know what the issue is, but adding this check should prevent repos
> from getting in this state, and should help us pinpoint the issue next time
> it happens.
> 
> diff --git a/mercurial/revlog.py b/mercurial/revlog.py
> --- a/mercurial/revlog.py
> +++ b/mercurial/revlog.py
> @@ -991,6 +991,9 @@
>         p1, p2 - the parent nodeids of the revision
>         cachedelta - an optional precomputed delta
>         """
> +        if link == nullrev:
> +            raise RevlogError(_("attempted to add linkrev -1 to %s")
> +                              % self.indexfile)
>         node = hash(text, p1, p2)
>         if node in self.nodemap:
>             return node
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Augie Fackler - June 21, 2013, 8:53 p.m.
Queued, thanks.

On Tue, Jun 18, 2013 at 8:28 AM, Augie Fackler <raf@durin42.com> wrote:
> LGTM
>
> (In an airport, too lazy to queue right now.)
>
> On Jun 17, 2013, at 10:47 PM, Durham Goode <durham@fb.com> wrote:
>
>> # HG changeset patch
>> # User Durham Goode <durham@fb.com>
>> # Date 1371523440 25200
>> #      Mon Jun 17 19:44:00 2013 -0700
>> # Node ID 275d78d339cc7d954952f9a17ecaad4d098073ff
>> # Parent  2d03c8da7d981a101c5f4d8dd5f9a55eb778033f
>> revlog: add exception when linkrev == nullrev
>>
>> When we deployed the latest crew mercurial to our users, a few of them
>> had issues where a filelog would have an entry with a -1 linkrev. This
>> caused operations like rebase and amend to create a bundle containing the
>> entire repository, which took a long time.
>>
>> I don't know what the issue is, but adding this check should prevent repos
>> from getting in this state, and should help us pinpoint the issue next time
>> it happens.
>>
>> diff --git a/mercurial/revlog.py b/mercurial/revlog.py
>> --- a/mercurial/revlog.py
>> +++ b/mercurial/revlog.py
>> @@ -991,6 +991,9 @@
>>         p1, p2 - the parent nodeids of the revision
>>         cachedelta - an optional precomputed delta
>>         """
>> +        if link == nullrev:
>> +            raise RevlogError(_("attempted to add linkrev -1 to %s")
>> +                              % self.indexfile)
>>         node = hash(text, p1, p2)
>>         if node in self.nodemap:
>>             return node
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel@selenic.com
>> http://selenic.com/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -991,6 +991,9 @@ 
         p1, p2 - the parent nodeids of the revision
         cachedelta - an optional precomputed delta
         """
+        if link == nullrev:
+            raise RevlogError(_("attempted to add linkrev -1 to %s")
+                              % self.indexfile)
         node = hash(text, p1, p2)
         if node in self.nodemap:
             return node