[PATCH] discovery: improve some dealing with nullrev

Boris Feld boris.feld at octobus.net
Tue Jan 15 19:38:59 UTC 2019


# HG changeset patch
# User Boris Feld <boris.feld at 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
 
 def findcommonheads(ui, local, remote,
                     initialsamplesize=100,


More information about the Mercurial-devel mailing list