Submitter | Gregory Szorc |
---|---|
Date | March 28, 2017, 9:41 p.m. |
Message ID | <cf6393b6a3503f8885b7.1490737273@ubuntu-vm-main> |
Download | mbox | patch |
Permalink | /patch/19805/ |
State | Accepted |
Headers | show |
Comments
Looks prefect. Thanks for the fix! Excerpts from Gregory Szorc's message of 2017-03-28 14:41:13 -0700: > # HG changeset patch > # User Gregory Szorc <gregory.szorc@gmail.com> > # Date 1490737213 25200 > # Tue Mar 28 14:40:13 2017 -0700 > # Node ID cf6393b6a3503f8885b704407e5bd58a89b96dfe > # Parent e86eb75e74ce1b0803c26d86a229b9b711f6d76a > fileset: perform membership test against set for status queries > > Previously, fileset functions operating on status items performed > membership tests against a list of items. When there are thousands > of items having a specific status, that test can be extremely > slow. Changing the membership test to a set makes this operation > substantially faster. > > On the mozilla-central repo: > > $ hg files -r d14cac631ecc 'set:added()' > before: 28.120s > after: 0.860s > > $ hg status --change d14cac631ecc --added > 0.690s > > diff --git a/mercurial/fileset.py b/mercurial/fileset.py > --- a/mercurial/fileset.py > +++ b/mercurial/fileset.py > @@ -154,7 +154,7 @@ def modified(mctx, x): > """ > # i18n: "modified" is a keyword > getargs(x, 0, 0, _("modified takes no arguments")) > - s = mctx.status().modified > + s = set(mctx.status().modified) > return [f for f in mctx.subset if f in s] > > @predicate('added()', callstatus=True) > @@ -163,7 +163,7 @@ def added(mctx, x): > """ > # i18n: "added" is a keyword > getargs(x, 0, 0, _("added takes no arguments")) > - s = mctx.status().added > + s = set(mctx.status().added) > return [f for f in mctx.subset if f in s] > > @predicate('removed()', callstatus=True) > @@ -172,7 +172,7 @@ def removed(mctx, x): > """ > # i18n: "removed" is a keyword > getargs(x, 0, 0, _("removed takes no arguments")) > - s = mctx.status().removed > + s = set(mctx.status().removed) > return [f for f in mctx.subset if f in s] > > @predicate('deleted()', callstatus=True) > @@ -181,7 +181,7 @@ def deleted(mctx, x): > """ > # i18n: "deleted" is a keyword > getargs(x, 0, 0, _("deleted takes no arguments")) > - s = mctx.status().deleted > + s = set(mctx.status().deleted) > return [f for f in mctx.subset if f in s] > > @predicate('missing()', callstatus=True) > @@ -190,7 +190,7 @@ def missing(mctx, x): > """ > # i18n: "missing" is a keyword > getargs(x, 0, 0, _("missing takes no arguments")) > - s = mctx.status().deleted > + s = set(mctx.status().deleted) > return [f for f in mctx.subset if f in s] > > @predicate('unknown()', callstatus=True) > @@ -200,7 +200,7 @@ def unknown(mctx, x): > """ > # i18n: "unknown" is a keyword > getargs(x, 0, 0, _("unknown takes no arguments")) > - s = mctx.status().unknown > + s = set(mctx.status().unknown) > return [f for f in mctx.subset if f in s] > > @predicate('ignored()', callstatus=True) > @@ -210,7 +210,7 @@ def ignored(mctx, x): > """ > # i18n: "ignored" is a keyword > getargs(x, 0, 0, _("ignored takes no arguments")) > - s = mctx.status().ignored > + s = set(mctx.status().ignored) > return [f for f in mctx.subset if f in s] > > @predicate('clean()', callstatus=True) > @@ -219,7 +219,7 @@ def clean(mctx, x): > """ > # i18n: "clean" is a keyword > getargs(x, 0, 0, _("clean takes no arguments")) > - s = mctx.status().clean > + s = set(mctx.status().clean) > return [f for f in mctx.subset if f in s] > > def func(mctx, a, b):
On 3/28/17 10:41 PM, Gregory Szorc wrote: > # HG changeset patch > # User Gregory Szorc <gregory.szorc@gmail.com> > # Date 1490737213 25200 > # Tue Mar 28 14:40:13 2017 -0700 > # Node ID cf6393b6a3503f8885b704407e5bd58a89b96dfe > # Parent e86eb75e74ce1b0803c26d86a229b9b711f6d76a > fileset: perform membership test against set for status queries > > Previously, fileset functions operating on status items performed > membership tests against a list of items. When there are thousands > of items having a specific status, that test can be extremely > slow. Changing the membership test to a set makes this operation > substantially faster. > > On the mozilla-central repo: > > $ hg files -r d14cac631ecc 'set:added()' > before: 28.120s > after: 0.860s > > $ hg status --change d14cac631ecc --added > 0.690s Awesome wins! > > diff --git a/mercurial/fileset.py b/mercurial/fileset.py > --- a/mercurial/fileset.py > +++ b/mercurial/fileset.py > @@ -154,7 +154,7 @@ def modified(mctx, x): > """ > # i18n: "modified" is a keyword > getargs(x, 0, 0, _("modified takes no arguments")) > - s = mctx.status().modified > + s = set(mctx.status().modified) > return [f for f in mctx.subset if f in s] > > @predicate('added()', callstatus=True) > @@ -163,7 +163,7 @@ def added(mctx, x): > """ > # i18n: "added" is a keyword > getargs(x, 0, 0, _("added takes no arguments")) > - s = mctx.status().added > + s = set(mctx.status().added) > return [f for f in mctx.subset if f in s] > > @predicate('removed()', callstatus=True) > @@ -172,7 +172,7 @@ def removed(mctx, x): > """ > # i18n: "removed" is a keyword > getargs(x, 0, 0, _("removed takes no arguments")) > - s = mctx.status().removed > + s = set(mctx.status().removed) > return [f for f in mctx.subset if f in s] > > @predicate('deleted()', callstatus=True) > @@ -181,7 +181,7 @@ def deleted(mctx, x): > """ > # i18n: "deleted" is a keyword > getargs(x, 0, 0, _("deleted takes no arguments")) > - s = mctx.status().deleted > + s = set(mctx.status().deleted) > return [f for f in mctx.subset if f in s] > > @predicate('missing()', callstatus=True) > @@ -190,7 +190,7 @@ def missing(mctx, x): > """ > # i18n: "missing" is a keyword > getargs(x, 0, 0, _("missing takes no arguments")) > - s = mctx.status().deleted > + s = set(mctx.status().deleted) > return [f for f in mctx.subset if f in s] > > @predicate('unknown()', callstatus=True) > @@ -200,7 +200,7 @@ def unknown(mctx, x): > """ > # i18n: "unknown" is a keyword > getargs(x, 0, 0, _("unknown takes no arguments")) > - s = mctx.status().unknown > + s = set(mctx.status().unknown) > return [f for f in mctx.subset if f in s] > > @predicate('ignored()', callstatus=True) > @@ -210,7 +210,7 @@ def ignored(mctx, x): > """ > # i18n: "ignored" is a keyword > getargs(x, 0, 0, _("ignored takes no arguments")) > - s = mctx.status().ignored > + s = set(mctx.status().ignored) > return [f for f in mctx.subset if f in s] > > @predicate('clean()', callstatus=True) > @@ -219,7 +219,7 @@ def clean(mctx, x): > """ > # i18n: "clean" is a keyword > getargs(x, 0, 0, _("clean takes no arguments")) > - s = mctx.status().clean > + s = set(mctx.status().clean) > return [f for f in mctx.subset if f in s] > > def func(mctx, a, b): > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@mercurial-scm.org > https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mercurial-2Dscm.org_mailman_listinfo_mercurial-2Ddevel&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=Jw8rundaE7TbmqBYd1txIQ&m=edTTPnGsU5TpZqUPbfCPFWf3rectVfwwstyAAhtMd-I&s=Ps9VA8fsYq8O0ZvQKOjpzRj0sJKYpO3-MdQEB-o59Fg&e=
On Tue, 28 Mar 2017 14:41:13 -0700, Gregory Szorc wrote: > # HG changeset patch > # User Gregory Szorc <gregory.szorc@gmail.com> > # Date 1490737213 25200 > # Tue Mar 28 14:40:13 2017 -0700 > # Node ID cf6393b6a3503f8885b704407e5bd58a89b96dfe > # Parent e86eb75e74ce1b0803c26d86a229b9b711f6d76a > fileset: perform membership test against set for status queries Nice. Queued, thanks.
Patch
diff --git a/mercurial/fileset.py b/mercurial/fileset.py --- a/mercurial/fileset.py +++ b/mercurial/fileset.py @@ -154,7 +154,7 @@ def modified(mctx, x): """ # i18n: "modified" is a keyword getargs(x, 0, 0, _("modified takes no arguments")) - s = mctx.status().modified + s = set(mctx.status().modified) return [f for f in mctx.subset if f in s] @predicate('added()', callstatus=True) @@ -163,7 +163,7 @@ def added(mctx, x): """ # i18n: "added" is a keyword getargs(x, 0, 0, _("added takes no arguments")) - s = mctx.status().added + s = set(mctx.status().added) return [f for f in mctx.subset if f in s] @predicate('removed()', callstatus=True) @@ -172,7 +172,7 @@ def removed(mctx, x): """ # i18n: "removed" is a keyword getargs(x, 0, 0, _("removed takes no arguments")) - s = mctx.status().removed + s = set(mctx.status().removed) return [f for f in mctx.subset if f in s] @predicate('deleted()', callstatus=True) @@ -181,7 +181,7 @@ def deleted(mctx, x): """ # i18n: "deleted" is a keyword getargs(x, 0, 0, _("deleted takes no arguments")) - s = mctx.status().deleted + s = set(mctx.status().deleted) return [f for f in mctx.subset if f in s] @predicate('missing()', callstatus=True) @@ -190,7 +190,7 @@ def missing(mctx, x): """ # i18n: "missing" is a keyword getargs(x, 0, 0, _("missing takes no arguments")) - s = mctx.status().deleted + s = set(mctx.status().deleted) return [f for f in mctx.subset if f in s] @predicate('unknown()', callstatus=True) @@ -200,7 +200,7 @@ def unknown(mctx, x): """ # i18n: "unknown" is a keyword getargs(x, 0, 0, _("unknown takes no arguments")) - s = mctx.status().unknown + s = set(mctx.status().unknown) return [f for f in mctx.subset if f in s] @predicate('ignored()', callstatus=True) @@ -210,7 +210,7 @@ def ignored(mctx, x): """ # i18n: "ignored" is a keyword getargs(x, 0, 0, _("ignored takes no arguments")) - s = mctx.status().ignored + s = set(mctx.status().ignored) return [f for f in mctx.subset if f in s] @predicate('clean()', callstatus=True) @@ -219,7 +219,7 @@ def clean(mctx, x): """ # i18n: "clean" is a keyword getargs(x, 0, 0, _("clean takes no arguments")) - s = mctx.status().clean + s = set(mctx.status().clean) return [f for f in mctx.subset if f in s] def func(mctx, a, b):