Patchwork changelog: make native head computation aware of filtering

login
register
mail settings
Submitter Laurent Charignon
Date May 20, 2015, 11:01 p.m.
Message ID <a89ff1dfbc175d72d665.1432162890@lcharignon-mbp.local>
Download mbox | patch
Permalink /patch/9202/
State Changes Requested
Headers show

Comments

Laurent Charignon - May 20, 2015, 11:01 p.m.
# HG changeset patch
# User Laurent Charignon <lcharignon@fb.com>
# Date 1432162260 25200
#      Wed May 20 15:51:00 2015 -0700
# Node ID a89ff1dfbc175d72d6654ec6e94e52fe81c1875c
# Parent  a39c35e8e559e238f311c647679e8de3b91748c6
changelog: make native head computation aware of filtering

The code to compute the heads natively was returning all of the heads of
the repository regardless of filtering state. This patch makes the native
implementation of headrevs() discard the filtered heads matching the pure
implementation.
Pierre-Yves David - May 20, 2015, 11:09 p.m.
On 05/20/2015 06:01 PM, Laurent Charignon wrote:
> # HG changeset patch
> # User Laurent Charignon <lcharignon@fb.com>
> # Date 1432162260 25200
> #      Wed May 20 15:51:00 2015 -0700
> # Node ID a89ff1dfbc175d72d6654ec6e94e52fe81c1875c
> # Parent  a39c35e8e559e238f311c647679e8de3b91748c6
> changelog: make native head computation aware of filtering
>
> The code to compute the heads natively was returning all of the heads of
> the repository regardless of filtering state. This patch makes the native
> implementation of headrevs() discard the filtered heads matching the pure
> implementation.
>
> diff --git a/mercurial/changelog.py b/mercurial/changelog.py
> --- a/mercurial/changelog.py
> +++ b/mercurial/changelog.py
> @@ -175,7 +175,9 @@
>       def headrevs(self):
>           if self.filteredrevs:
>               try:
> -                return self.index.headrevsfiltered(self.filteredrevs)
> +                return [h for h
> +                          in self.index.headrevsfiltered(self.filteredrevs)
> +                          if h not in self.filteredrevs]

This "does not make senses to me"².

1) the reason for which we pass 'self.filteredrevs' to 
'headrevsfiltered' is for it to respect this filtering. If it return 
anything unfiltered it is clearly not doing its job.

2) You cannot just drop filtered head like that. consider the following 
case:

   x B
   |
   o A
   |

Unfiltered heads are [B].
visible heads are [A].

Just dropping filtered entry from unfiltered heads would give your 
"visible heads are []".
Laurent Charignon - May 20, 2015, 11:41 p.m.
On 5/20/15, 4:09 PM, "Pierre-Yves David" <pierre-yves.david@ens-lyon.org>
wrote:

>

>

>On 05/20/2015 06:01 PM, Laurent Charignon wrote:

>> # HG changeset patch

>> # User Laurent Charignon <lcharignon@fb.com>

>> # Date 1432162260 25200

>> #      Wed May 20 15:51:00 2015 -0700

>> # Node ID a89ff1dfbc175d72d6654ec6e94e52fe81c1875c

>> # Parent  a39c35e8e559e238f311c647679e8de3b91748c6

>> changelog: make native head computation aware of filtering

>>

>> The code to compute the heads natively was returning all of the heads of

>> the repository regardless of filtering state. This patch makes the

>>native

>> implementation of headrevs() discard the filtered heads matching the

>>pure

>> implementation.

>>

>> diff --git a/mercurial/changelog.py b/mercurial/changelog.py

>> --- a/mercurial/changelog.py

>> +++ b/mercurial/changelog.py

>> @@ -175,7 +175,9 @@

>>       def headrevs(self):

>>           if self.filteredrevs:

>>               try:

>> -                return self.index.headrevsfiltered(self.filteredrevs)

>> +                return [h for h

>> +                          in

>>self.index.headrevsfiltered(self.filteredrevs)

>> +                          if h not in self.filteredrevs]

>

>This "does not make senses to me"².

>

>1) the reason for which we pass 'self.filteredrevs' to

>'headrevsfiltered' is for it to respect this filtering. If it return

>anything unfiltered it is clearly not doing its job.

>

>2) You cannot just drop filtered head like that. consider the following

>case:

>

>   x B

>   |

>   o A

>   |

>

>Unfiltered heads are [B].

>visible heads are [A].

>

>Just dropping filtered entry from unfiltered heads would give your

>"visible heads are []".


I will look into it again
>

>

>-- 

>Pierre-Yves David

Patch

diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -175,7 +175,9 @@ 
     def headrevs(self):
         if self.filteredrevs:
             try:
-                return self.index.headrevsfiltered(self.filteredrevs)
+                return [h for h
+                          in self.index.headrevsfiltered(self.filteredrevs)
+                          if h not in self.filteredrevs]
             # AttributeError covers non-c-extension environments and
             # old c extensions without filter handling.
             except AttributeError: