Patchwork metadataonlyctx: speed up sanity check

login
register
mail settings
Submitter Jun Wu
Date March 26, 2017, 7:32 p.m.
Message ID <2793d297600133bb83a5.1490556743@localhost.localdomain>
Download mbox | patch
Permalink /patch/19698/
State Accepted
Headers show

Comments

Jun Wu - March 26, 2017, 7:32 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1490556395 25200
#      Sun Mar 26 12:26:35 2017 -0700
# Node ID 2793d297600133bb83a5d2f5a46bfa3fadd037ab
# Parent  b6766d75404fb8c5d26af016caa76f44b47ce156
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 2793d2976001
metadataonlyctx: speed up sanity check

Previously the sanity check will construct manifestctx for both p1 and p2.
But it only needs the "manifest node" information, which could be read from
changelog directly.
Ryan McElroy - March 27, 2017, 2:11 p.m.
(cc Mateusz)

On 3/26/17 8:32 PM, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark@fb.com>
> # Date 1490556395 25200
> #      Sun Mar 26 12:26:35 2017 -0700
> # Node ID 2793d297600133bb83a5d2f5a46bfa3fadd037ab
> # Parent  b6766d75404fb8c5d26af016caa76f44b47ce156
> metadataonlyctx: speed up sanity check
>
> Previously the sanity check will construct manifestctx for both p1 and p2.
> But it only needs the "manifest node" information, which could be read from
> changelog directly.
>
> diff --git a/mercurial/context.py b/mercurial/context.py
> --- a/mercurial/context.py
> +++ b/mercurial/context.py
> @@ -2061,8 +2061,8 @@ class metadataonlyctx(committablectx):
>           # manifests of our commit parents
>           mp1, mp2 = self.manifestctx().parents
> -        if p1 != nullid and p1.manifestctx().node() != mp1:
> +        if p1 != nullid and p1.changeset()[0] != mp1:
>               raise RuntimeError('can\'t reuse the manifest: '
>                                  'its p1 doesn\'t match the new ctx p1')
> -        if p2 != nullid and p2.manifestctx().node() != mp2:
> +        if p2 != nullid and p2.changeset()[0] != mp2:
>               raise RuntimeError('can\'t reuse the manifest: '
>                                  'its p2 doesn\'t match the new ctx p2')
>

This change looks good to me, thanks! Marked as pre-reviewed.
Yuya Nishihara - March 27, 2017, 3:48 p.m.
On Sun, 26 Mar 2017 12:32:23 -0700, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark@fb.com>
> # Date 1490556395 25200
> #      Sun Mar 26 12:26:35 2017 -0700
> # Node ID 2793d297600133bb83a5d2f5a46bfa3fadd037ab
> # Parent  b6766d75404fb8c5d26af016caa76f44b47ce156
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r 2793d2976001
> metadataonlyctx: speed up sanity check
> 
> Previously the sanity check will construct manifestctx for both p1 and p2.
> But it only needs the "manifest node" information, which could be read from
> changelog directly.
> 
> diff --git a/mercurial/context.py b/mercurial/context.py
> --- a/mercurial/context.py
> +++ b/mercurial/context.py
> @@ -2061,8 +2061,8 @@ class metadataonlyctx(committablectx):
>          # manifests of our commit parents
>          mp1, mp2 = self.manifestctx().parents
> -        if p1 != nullid and p1.manifestctx().node() != mp1:
> +        if p1 != nullid and p1.changeset()[0] != mp1:
>              raise RuntimeError('can\'t reuse the manifest: '
>                                 'its p1 doesn\'t match the new ctx p1')
> -        if p2 != nullid and p2.manifestctx().node() != mp2:
> +        if p2 != nullid and p2.changeset()[0] != mp2:

Perhaps ctx.manifestnode() can be used.
Augie Fackler - March 27, 2017, 4:32 p.m.
On Sun, Mar 26, 2017 at 12:32:23PM -0700, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark@fb.com>
> # Date 1490556395 25200
> #      Sun Mar 26 12:26:35 2017 -0700
> # Node ID 2793d297600133bb83a5d2f5a46bfa3fadd037ab
> # Parent  b6766d75404fb8c5d26af016caa76f44b47ce156
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r 2793d2976001
> metadataonlyctx: speed up sanity check

Queued this, thanks.

>
> Previously the sanity check will construct manifestctx for both p1 and p2.
> But it only needs the "manifest node" information, which could be read from
> changelog directly.
>
> diff --git a/mercurial/context.py b/mercurial/context.py
> --- a/mercurial/context.py
> +++ b/mercurial/context.py
> @@ -2061,8 +2061,8 @@ class metadataonlyctx(committablectx):
>          # manifests of our commit parents
>          mp1, mp2 = self.manifestctx().parents
> -        if p1 != nullid and p1.manifestctx().node() != mp1:
> +        if p1 != nullid and p1.changeset()[0] != mp1:
>              raise RuntimeError('can\'t reuse the manifest: '
>                                 'its p1 doesn\'t match the new ctx p1')
> -        if p2 != nullid and p2.manifestctx().node() != mp2:
> +        if p2 != nullid and p2.changeset()[0] != mp2:
>              raise RuntimeError('can\'t reuse the manifest: '
>                                 'its p2 doesn\'t match the new ctx p2')
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -2061,8 +2061,8 @@  class metadataonlyctx(committablectx):
         # manifests of our commit parents
         mp1, mp2 = self.manifestctx().parents
-        if p1 != nullid and p1.manifestctx().node() != mp1:
+        if p1 != nullid and p1.changeset()[0] != mp1:
             raise RuntimeError('can\'t reuse the manifest: '
                                'its p1 doesn\'t match the new ctx p1')
-        if p2 != nullid and p2.manifestctx().node() != mp2:
+        if p2 != nullid and p2.changeset()[0] != mp2:
             raise RuntimeError('can\'t reuse the manifest: '
                                'its p2 doesn\'t match the new ctx p2')