Patchwork [3,of,8] hidden: add a function returning ancestors of revs within a domain

login
register
mail settings
Submitter Pierre-Yves David
Date May 21, 2017, 3:20 p.m.
Message ID <bde4b1ab7b0111988a52.1495380038@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/20788/
State Accepted
Headers show

Comments

Pierre-Yves David - May 21, 2017, 3:20 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1495372906 -7200
#      Sun May 21 15:21:46 2017 +0200
# Node ID bde4b1ab7b0111988a521c4c4c28b3963010eeff
# Parent  acd7e055dbcb5830de634f52971a39dc654d73e1
# EXP-Topic dynamicblocker
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r bde4b1ab7b01
hidden: add a function returning ancestors of revs within a domain

See documentation for details. This will be used to improve the hidden
computation algorithm. See new changesets for usage.
Augie Fackler - May 22, 2017, 10 p.m.
On Sun, May 21, 2017 at 05:20:38PM +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@octobus.net>
> # Date 1495372906 -7200
> #      Sun May 21 15:21:46 2017 +0200
> # Node ID bde4b1ab7b0111988a521c4c4c28b3963010eeff
> # Parent  acd7e055dbcb5830de634f52971a39dc654d73e1
> # EXP-Topic dynamicblocker
> # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
> #              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r bde4b1ab7b01
> hidden: add a function returning ancestors of revs within a domain
>
> See documentation for details. This will be used to improve the hidden
> computation algorithm. See new changesets for usage.
>
> diff --git a/mercurial/repoview.py b/mercurial/repoview.py
> --- a/mercurial/repoview.py
> +++ b/mercurial/repoview.py
> @@ -92,6 +92,29 @@ def _getstatichidden(repo):
>                      heappush(heap, -parent)
>      return hidden
>
> +def _domainancestors(pfunc, revs, domain):
> +    """return ancestors of 'revs' within 'domain'
> +
> +    - pfunc(r): a funtion returning parent of 'r',
                      ^ function (please double-check your spellchecker?)


> +    - revs: iterable of revnum,
> +    - domain: consistent set of revnum.

I'm not sure what "consistent set of revnum" means, which makes the docstring not useful.

> +
> +    The domain must be consistent, no connected set are the ancestors of another
> +    connected set.

I can't parse this definition either. :(

> +
> +    (Ancestors are returned inclusively)
> +    """
> +    stack = list(revs)
> +    ancs = set(stack)
> +    while stack:
> +        for p in pfunc(stack.pop()):
> +            nbanc = len(ancs)
> +            if p != nullrev and p in domain:
> +                ancs.add(p)
> +            if nbanc != len(ancs): # avoid double membership testing
> +                stack.append(p)
> +    return ancs
> +
>  cacheversion = 1
>  cachefile = 'cache/hidden'
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
via Mercurial-devel - May 23, 2017, 9:35 p.m.
On Mon, May 22, 2017 at 3:00 PM, Augie Fackler <raf@durin42.com> wrote:
> On Sun, May 21, 2017 at 05:20:38PM +0200, Pierre-Yves David wrote:
>> # HG changeset patch
>> # User Pierre-Yves David <pierre-yves.david@octobus.net>
>> # Date 1495372906 -7200
>> #      Sun May 21 15:21:46 2017 +0200
>> # Node ID bde4b1ab7b0111988a521c4c4c28b3963010eeff
>> # Parent  acd7e055dbcb5830de634f52971a39dc654d73e1
>> # EXP-Topic dynamicblocker
>> # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
>> #              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r bde4b1ab7b01
>> hidden: add a function returning ancestors of revs within a domain
>>
>> See documentation for details. This will be used to improve the hidden
>> computation algorithm. See new changesets for usage.
>>
>> diff --git a/mercurial/repoview.py b/mercurial/repoview.py
>> --- a/mercurial/repoview.py
>> +++ b/mercurial/repoview.py
>> @@ -92,6 +92,29 @@ def _getstatichidden(repo):
>>                      heappush(heap, -parent)
>>      return hidden
>>
>> +def _domainancestors(pfunc, revs, domain):
>> +    """return ancestors of 'revs' within 'domain'
>> +
>> +    - pfunc(r): a funtion returning parent of 'r',
>                       ^ function (please double-check your spellchecker?)
>
>
>> +    - revs: iterable of revnum,
>> +    - domain: consistent set of revnum.
>
> I'm not sure what "consistent set of revnum" means, which makes the docstring not useful.

Maybe Pierre-Yves meant "contiguous"? I can fix in flight if that's
what it was meant to be (assuming it looks good otherwise; I haven't
started reviewing).

>
>> +
>> +    The domain must be consistent, no connected set are the ancestors of another
>> +    connected set.
>
> I can't parse this definition either. :(

I'm not sure I can either. With the history below, it sounds like B
and C can be in the domain, but A cannot. Correct?

B C
| /
A

>
>> +
>> +    (Ancestors are returned inclusively)
>> +    """
>> +    stack = list(revs)
>> +    ancs = set(stack)
>> +    while stack:
>> +        for p in pfunc(stack.pop()):
>> +            nbanc = len(ancs)
>> +            if p != nullrev and p in domain:
>> +                ancs.add(p)
>> +            if nbanc != len(ancs): # avoid double membership testing
>> +                stack.append(p)
>> +    return ancs
>> +
>>  cacheversion = 1
>>  cachefile = 'cache/hidden'
>>
>> _______________________________________________
>> Mercurial-devel mailing list
>> 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
Pierre-Yves David - May 24, 2017, 1:43 p.m.
On 05/23/2017 11:35 PM, Martin von Zweigbergk wrote:
> On Mon, May 22, 2017 at 3:00 PM, Augie Fackler <raf@durin42.com> wrote:
>> On Sun, May 21, 2017 at 05:20:38PM +0200, Pierre-Yves David wrote:
>>> # HG changeset patch
>>> # User Pierre-Yves David <pierre-yves.david@octobus.net>
>>> # Date 1495372906 -7200
>>> #      Sun May 21 15:21:46 2017 +0200
>>> # Node ID bde4b1ab7b0111988a521c4c4c28b3963010eeff
>>> # Parent  acd7e055dbcb5830de634f52971a39dc654d73e1
>>> # EXP-Topic dynamicblocker
>>> # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
>>> #              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r bde4b1ab7b01
>>> hidden: add a function returning ancestors of revs within a domain
>>>
>>> See documentation for details. This will be used to improve the hidden
>>> computation algorithm. See new changesets for usage.
>>>
>>> diff --git a/mercurial/repoview.py b/mercurial/repoview.py
>>> --- a/mercurial/repoview.py
>>> +++ b/mercurial/repoview.py
>>> @@ -92,6 +92,29 @@ def _getstatichidden(repo):
>>>                      heappush(heap, -parent)
>>>      return hidden
>>>
>>> +def _domainancestors(pfunc, revs, domain):
>>> +    """return ancestors of 'revs' within 'domain'
>>> +
>>> +    - pfunc(r): a funtion returning parent of 'r',
>>                       ^ function (please double-check your spellchecker?)
>>
>>
>>> +    - revs: iterable of revnum,
>>> +    - domain: consistent set of revnum.
>>
>> I'm not sure what "consistent set of revnum" means, which makes the docstring not useful.
>
> Maybe Pierre-Yves meant "contiguous"? I can fix in flight if that's
> what it was meant to be (assuming it looks good otherwise; I haven't
> started reviewing).

I do not mean contiguous. The domains can have multiple disconnected 
"subset", but these "subset" are not ancestors of each other.

If that helps. "domain" will be all revision in "not public()" They can 
be on disconnect "branch", but these subset will all be based only on 
public changeset outside the "domain"

>
>>
>>> +
>>> +    The domain must be consistent, no connected set are the ancestors of another
>>> +    connected set.
>>
>> I can't parse this definition either. :(
>
> I'm not sure I can either. With the history below, it sounds like B
> and C can be in the domain, but A cannot. Correct?
>
> B C
> | /
> A

Can you check my explanation my rephrasing in V2 to see if it clarifies it?


>
>>
>>> +
>>> +    (Ancestors are returned inclusively)
>>> +    """
>>> +    stack = list(revs)
>>> +    ancs = set(stack)
>>> +    while stack:
>>> +        for p in pfunc(stack.pop()):
>>> +            nbanc = len(ancs)
>>> +            if p != nullrev and p in domain:
>>> +                ancs.add(p)
>>> +            if nbanc != len(ancs): # avoid double membership testing
>>> +                stack.append(p)
>>> +    return ancs
>>> +
>>>  cacheversion = 1
>>>  cachefile = 'cache/hidden'
>>>
>>> _______________________________________________
>>> Mercurial-devel mailing list
>>> 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
via Mercurial-devel - May 24, 2017, 2 p.m.
On Wed, May 24, 2017, 06:43 Pierre-Yves David <
pierre-yves.david@ens-lyon.org> wrote:

>
>
> On 05/23/2017 11:35 PM, Martin von Zweigbergk wrote:
> > On Mon, May 22, 2017 at 3:00 PM, Augie Fackler <raf@durin42.com> wrote:
> >> On Sun, May 21, 2017 at 05:20:38PM +0200, Pierre-Yves David wrote:
> >>> # HG changeset patch
> >>> # User Pierre-Yves David <pierre-yves.david@octobus.net>
> >>> # Date 1495372906 -7200
> >>> #      Sun May 21 15:21:46 2017 +0200
> >>> # Node ID bde4b1ab7b0111988a521c4c4c28b3963010eeff
> >>> # Parent  acd7e055dbcb5830de634f52971a39dc654d73e1
> >>> # EXP-Topic dynamicblocker
> >>> # Available At
> https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
> >>> #              hg pull
> https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r
> bde4b1ab7b01
> >>> hidden: add a function returning ancestors of revs within a domain
> >>>
> >>> See documentation for details. This will be used to improve the hidden
> >>> computation algorithm. See new changesets for usage.
> >>>
> >>> diff --git a/mercurial/repoview.py b/mercurial/repoview.py
> >>> --- a/mercurial/repoview.py
> >>> +++ b/mercurial/repoview.py
> >>> @@ -92,6 +92,29 @@ def _getstatichidden(repo):
> >>>                      heappush(heap, -parent)
> >>>      return hidden
> >>>
> >>> +def _domainancestors(pfunc, revs, domain):
> >>> +    """return ancestors of 'revs' within 'domain'
> >>> +
> >>> +    - pfunc(r): a funtion returning parent of 'r',
> >>                       ^ function (please double-check your
> spellchecker?)
> >>
> >>
> >>> +    - revs: iterable of revnum,
> >>> +    - domain: consistent set of revnum.
> >>
> >> I'm not sure what "consistent set of revnum" means, which makes the
> docstring not useful.
> >
> > Maybe Pierre-Yves meant "contiguous"? I can fix in flight if that's
> > what it was meant to be (assuming it looks good otherwise; I haven't
> > started reviewing).
>
> I do not mean contiguous. The domains can have multiple disconnected
> "subset", but these "subset" are not ancestors of each other.
>
> If that helps. "domain" will be all revision in "not public()" They can
> be on disconnect "branch", but these subset will all be based only on
> public changeset outside the "domain"
>
> >
> >>
> >>> +
> >>> +    The domain must be consistent, no connected set are the ancestors
> of another
> >>> +    connected set.
> >>
> >> I can't parse this definition either. :(
> >
> > I'm not sure I can either. With the history below, it sounds like B
> > and C can be in the domain, but A cannot. Correct?
> >
> > B C
> > | /
> > A
>
> Can you check my explanation my rephrasing in V2 to see if it clarifies it?
>

I did before sending the above. I didn't even notice a difference in v2, or
at least not anything that helped me understand.

Was my example correct?


>
> >
> >>
> >>> +
> >>> +    (Ancestors are returned inclusively)
> >>> +    """
> >>> +    stack = list(revs)
> >>> +    ancs = set(stack)
> >>> +    while stack:
> >>> +        for p in pfunc(stack.pop()):
> >>> +            nbanc = len(ancs)
> >>> +            if p != nullrev and p in domain:
> >>> +                ancs.add(p)
> >>> +            if nbanc != len(ancs): # avoid double membership testing
> >>> +                stack.append(p)
> >>> +    return ancs
> >>> +
> >>>  cacheversion = 1
> >>>  cachefile = 'cache/hidden'
> >>>
> >>> _______________________________________________
> >>> Mercurial-devel mailing list
> >>> 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
>
> --
> Pierre-Yves David
>
Pierre-Yves David - May 24, 2017, 2:19 p.m.
On 05/24/2017 04:00 PM, Martin von Zweigbergk wrote:
>
>
> On Wed, May 24, 2017, 06:43 Pierre-Yves David
> <pierre-yves.david@ens-lyon.org <mailto:pierre-yves.david@ens-lyon.org>>
> wrote:
>
>
>
>     On 05/23/2017 11:35 PM, Martin von Zweigbergk wrote:
>     > On Mon, May 22, 2017 at 3:00 PM, Augie Fackler <raf@durin42.com
>     <mailto:raf@durin42.com>> wrote:
>     >> On Sun, May 21, 2017 at 05:20:38PM +0200, Pierre-Yves David wrote:
>     >>> # HG changeset patch
>     >>> # User Pierre-Yves David <pierre-yves.david@octobus.net
>     <mailto:pierre-yves.david@octobus.net>>
>     >>> # Date 1495372906 -7200
>     >>> #      Sun May 21 15:21:46 2017 +0200
>     >>> # Node ID bde4b1ab7b0111988a521c4c4c28b3963010eeff
>     >>> # Parent  acd7e055dbcb5830de634f52971a39dc654d73e1
>     >>> # EXP-Topic dynamicblocker
>     >>> # Available At
>     https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
>     >>> #              hg pull
>     https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r
>     bde4b1ab7b01
>     >>> hidden: add a function returning ancestors of revs within a domain
>     >>>
>     >>> See documentation for details. This will be used to improve the
>     hidden
>     >>> computation algorithm. See new changesets for usage.
>     >>>
>     >>> diff --git a/mercurial/repoview.py b/mercurial/repoview.py
>     >>> --- a/mercurial/repoview.py
>     >>> +++ b/mercurial/repoview.py
>     >>> @@ -92,6 +92,29 @@ def _getstatichidden(repo):
>     >>>                      heappush(heap, -parent)
>     >>>      return hidden
>     >>>
>     >>> +def _domainancestors(pfunc, revs, domain):
>     >>> +    """return ancestors of 'revs' within 'domain'
>     >>> +
>     >>> +    - pfunc(r): a funtion returning parent of 'r',
>     >>                       ^ function (please double-check your
>     spellchecker?)
>     >>
>     >>
>     >>> +    - revs: iterable of revnum,
>     >>> +    - domain: consistent set of revnum.
>     >>
>     >> I'm not sure what "consistent set of revnum" means, which makes
>     the docstring not useful.
>     >
>     > Maybe Pierre-Yves meant "contiguous"? I can fix in flight if that's
>     > what it was meant to be (assuming it looks good otherwise; I haven't
>     > started reviewing).
>
>     I do not mean contiguous. The domains can have multiple disconnected
>     "subset", but these "subset" are not ancestors of each other.
>
>     If that helps. "domain" will be all revision in "not public()" They can
>     be on disconnect "branch", but these subset will all be based only on
>     public changeset outside the "domain"
>
>     >
>     >>
>     >>> +
>     >>> +    The domain must be consistent, no connected set are the
>     ancestors of another
>     >>> +    connected set.
>     >>
>     >> I can't parse this definition either. :(
>     >
>     > I'm not sure I can either. With the history below, it sounds like B
>     > and C can be in the domain, but A cannot. Correct?
>     >
>     > B C
>     > | /
>     > A
>
>     Can you check my explanation my rephrasing in V2 to see if it
>     clarifies it?
>
>
> I did before sending the above. I didn't even notice a difference in v2,
> or at least not anything that helped me understand.
>
> Was my example correct?

nope :-/

   D
   | C
   |/
   B
   |
   A

If D and C are in the domain but B is not. A cannot be.

Patch

diff --git a/mercurial/repoview.py b/mercurial/repoview.py
--- a/mercurial/repoview.py
+++ b/mercurial/repoview.py
@@ -92,6 +92,29 @@  def _getstatichidden(repo):
                     heappush(heap, -parent)
     return hidden
 
+def _domainancestors(pfunc, revs, domain):
+    """return ancestors of 'revs' within 'domain'
+
+    - pfunc(r): a funtion returning parent of 'r',
+    - revs: iterable of revnum,
+    - domain: consistent set of revnum.
+
+    The domain must be consistent, no connected set are the ancestors of another
+    connected set.
+
+    (Ancestors are returned inclusively)
+    """
+    stack = list(revs)
+    ancs = set(stack)
+    while stack:
+        for p in pfunc(stack.pop()):
+            nbanc = len(ancs)
+            if p != nullrev and p in domain:
+                ancs.add(p)
+            if nbanc != len(ancs): # avoid double membership testing
+                stack.append(p)
+    return ancs
+
 cacheversion = 1
 cachefile = 'cache/hidden'