Patchwork discovery: improve some dealing with nullrev

login
register
mail settings
Submitter Boris Feld
Date Jan. 15, 2019, 7:38 p.m.
Message ID <b2b1b1f3a579d1d2ff88.1547581139@localhost.localdomain>
Download mbox | patch
Permalink /patch/37763/
State New
Headers show

Comments

Boris Feld - Jan. 15, 2019, 7:38 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1547465758 -3600
#      Mon Jan 14 12:35:58 2019 +0100
# Node ID b2b1b1f3a579d1d2ff880a2783e87fce72beee4e
# Parent  32ef47b3c91c2913ab13cabf9efcdde3ef137987
# EXP-Topic discovery.revset
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r b2b1b1f3a579
discovery: improve some dealing with nullrev

According to our testing, `heads()` is no longer confused by nullrev. So we
can avoid a potentially expensive iteration + testing.
Yuya Nishihara - Jan. 17, 2019, 11:31 a.m.
On Tue, 15 Jan 2019 20:38:59 +0100, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1547465758 -3600
> #      Mon Jan 14 12:35:58 2019 +0100
> # Node ID b2b1b1f3a579d1d2ff880a2783e87fce72beee4e
> # Parent  32ef47b3c91c2913ab13cabf9efcdde3ef137987
> # EXP-Topic discovery.revset
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r b2b1b1f3a579
> discovery: improve some dealing with nullrev
> 
> According to our testing, `heads()` is no longer confused by nullrev. So we
> can avoid a potentially expensive iteration + testing.
> 
> diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
> --- a/mercurial/setdiscovery.py
> +++ b/mercurial/setdiscovery.py
> @@ -230,8 +230,9 @@ class partialdiscovery(object):
>          # heads(common) == heads(common.bases) since common represents
>          # common.bases and all its ancestors
>          # The presence of nullrev will confuse heads(). So filter it out.
> -        return set(self._repo.revs('heads(%ld)',
> -                   self._common.bases - {nullrev}))
> +        heads = set(self._repo.revs('heads(%ld)', self._common.bases))
> +        heads.discard(nullrev)
> +        return heads

This should be superseded by 2a8782cc2e16, "discovery: using the new
basesheads()."

Patch

diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py
+++ b/mercurial/setdiscovery.py
@@ -230,8 +230,9 @@  class partialdiscovery(object):
         # heads(common) == heads(common.bases) since common represents
         # common.bases and all its ancestors
         # The presence of nullrev will confuse heads(). So filter it out.
-        return set(self._repo.revs('heads(%ld)',
-                   self._common.bases - {nullrev}))
+        heads = set(self._repo.revs('heads(%ld)', self._common.bases))
+        heads.discard(nullrev)
+        return heads
 
 def findcommonheads(ui, local, remote,
                     initialsamplesize=100,