Patchwork [2,of,2] ancestor: filter out initial revisions lower than stoprev

login
register
mail settings
Submitter Yuya Nishihara
Date Sept. 8, 2018, 2:51 a.m.
Message ID <4894b3cdd4c03bb5579b.1536375074@mimosa>
Download mbox | patch
Permalink /patch/34410/
State Changes Requested
Headers show

Comments

Yuya Nishihara - Sept. 8, 2018, 2:51 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1536371964 -32400
#      Sat Sep 08 10:59:24 2018 +0900
# Node ID 4894b3cdd4c03bb5579bb47f4f51a9410716df84
# Parent  ebcd7abf0d144fb657b90126a1e30d13eefeb364
ancestor: filter out initial revisions lower than stoprev
via Mercurial-devel - Sept. 8, 2018, 3:49 a.m.
Good catch. However, I think the docstring needs updating. I think it
explicitly said that inclusive mode emits the initial revs ignoring
stoprev. Will that still be the case after this patch? I'm on mobile right
now and too lazy to confirm, but hopefully I'm remembering it right.

On Fri, Sep 7, 2018, 19:54 Yuya Nishihara <yuya@tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1536371964 -32400
> #      Sat Sep 08 10:59:24 2018 +0900
> # Node ID 4894b3cdd4c03bb5579bb47f4f51a9410716df84
> # Parent  ebcd7abf0d144fb657b90126a1e30d13eefeb364
> ancestor: filter out initial revisions lower than stoprev
>
> diff --git a/mercurial/ancestor.py b/mercurial/ancestor.py
> --- a/mercurial/ancestor.py
> +++ b/mercurial/ancestor.py
> @@ -273,7 +273,7 @@ class lazyancestors(object):
>
>          Result does not include the null revision."""
>          self._parentrevs = pfunc
> -        self._initrevs = revs
> +        self._initrevs = revs = [r for r in revs if r >= stoprev]
>          self._stoprev = stoprev
>          self._inclusive = inclusive
>
> diff --git a/tests/test-ancestor.py.out b/tests/test-ancestor.py.out
> --- a/tests/test-ancestor.py.out
> +++ b/tests/test-ancestor.py.out
> @@ -20,5 +20,5 @@ iteration:  [13, 11, 8, 7]
>  membership: [11, 13]
>  iteration:  [13, 11]
>  % lazy ancestor set for [11, 13], stoprev = 12, inclusive = True
> -membership: [11, 13]
> +membership: [13]
>  iteration:  [13]
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
Yuya Nishihara - Sept. 8, 2018, 4:49 a.m.
On Fri, 7 Sep 2018 20:49:32 -0700, Martin von Zweigbergk wrote:
> Good catch. However, I think the docstring needs updating. I think it
> explicitly said that inclusive mode emits the initial revs ignoring
> stoprev.

That part was for __iter__(), and was rewritten by Boris' patch. The top-level
doc says:

 - inclusive is a boolean that indicates whether (init)revs should be included
 - revs lower than stoprev will not be generated
via Mercurial-devel - Sept. 8, 2018, 6:06 a.m.
On Fri, Sep 7, 2018 at 9:50 PM Yuya Nishihara <yuya@tcha.org> wrote:

> On Fri, 7 Sep 2018 20:49:32 -0700, Martin von Zweigbergk wrote:
> > Good catch. However, I think the docstring needs updating. I think it
> > explicitly said that inclusive mode emits the initial revs ignoring
> > stoprev.
>
> That part was for __iter__(), and was rewritten by Boris' patch.


Ah, right, I had already forgotten that. Sorry about the noise.

I'm queuing this series, thanks.

Patch

diff --git a/mercurial/ancestor.py b/mercurial/ancestor.py
--- a/mercurial/ancestor.py
+++ b/mercurial/ancestor.py
@@ -273,7 +273,7 @@  class lazyancestors(object):
 
         Result does not include the null revision."""
         self._parentrevs = pfunc
-        self._initrevs = revs
+        self._initrevs = revs = [r for r in revs if r >= stoprev]
         self._stoprev = stoprev
         self._inclusive = inclusive
 
diff --git a/tests/test-ancestor.py.out b/tests/test-ancestor.py.out
--- a/tests/test-ancestor.py.out
+++ b/tests/test-ancestor.py.out
@@ -20,5 +20,5 @@  iteration:  [13, 11, 8, 7]
 membership: [11, 13]
 iteration:  [13, 11]
 % lazy ancestor set for [11, 13], stoprev = 12, inclusive = True
-membership: [11, 13]
+membership: [13]
 iteration:  [13]