Patchwork [04,of,10,V3] discovery: move common heads computation inside partialdiscovery object

login
register
mail settings
Submitter Boris Feld
Date Jan. 4, 2019, 10:45 p.m.
Message ID <f3c439000eb772272745.1546641923@localhost.localdomain>
Download mbox | patch
Permalink /patch/37471/
State Accepted
Headers show

Comments

Boris Feld - Jan. 4, 2019, 10:45 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1545964082 -3600
#      Fri Dec 28 03:28:02 2018 +0100
# Node ID f3c439000eb772272745c344f5257f3ecce369c0
# Parent  18ff26b2cb10286556b57cc580bb4e76d84c5c10
# EXP-Topic discovery-refactor
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r f3c439000eb7
discovery: move common heads computation inside partialdiscovery object

This remove one of the private attribute access. In additions, head tracking
and computation is a typical operation we can speed up using Rust.
Pulkit Goyal - Jan. 5, 2019, 3:15 p.m.
On Sat, Jan 5, 2019 at 4:15 AM Boris Feld <boris.feld@octobus.net> wrote:

> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1545964082 -3600
> #      Fri Dec 28 03:28:02 2018 +0100
> # Node ID f3c439000eb772272745c344f5257f3ecce369c0
> # Parent  18ff26b2cb10286556b57cc580bb4e76d84c5c10
> # EXP-Topic discovery-refactor
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r
> f3c439000eb7
> discovery: move common heads computation inside partialdiscovery object
>
> This remove one of the private attribute access. In additions, head
> tracking
> and computation is a typical operation we can speed up using Rust.
>
> diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
> --- a/mercurial/setdiscovery.py
> +++ b/mercurial/setdiscovery.py
> @@ -182,6 +182,10 @@ class partialdiscovery(object):
>          """return True is we have any clue about the remote state"""
>          return self._common.hasbases()
>
> +    def commonheads(self):
> +        """the heads of the known common set"""
> +        return set(self._repo.revs('heads(%ld)',
> +                   self._common.bases - {nullrev}))
>
>  def findcommonheads(ui, local, remote,
>                      initialsamplesize=100,
> @@ -314,7 +318,7 @@ def findcommonheads(ui, local, remote,
>      # 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.
>

Moving this ^ comment to the new function created above.

> -    result = set(local.revs('heads(%ld)', disco._common.bases -
> {nullrev}))
> +    result = disco.commonheads()
>      elapsed = util.timer() - start
>      progress.complete()
>      ui.debug("%d total queries in %.4fs\n" % (roundtrips, elapsed))
>
Pulkit Goyal - Jan. 5, 2019, 3:27 p.m.
On Sat, Jan 5, 2019 at 8:45 PM Pulkit Goyal <7895pulkit@gmail.com> wrote:

>
>
> On Sat, Jan 5, 2019 at 4:15 AM Boris Feld <boris.feld@octobus.net> wrote:
>
>> # HG changeset patch
>> # User Boris Feld <boris.feld@octobus.net>
>> # Date 1545964082 -3600
>> #      Fri Dec 28 03:28:02 2018 +0100
>> # Node ID f3c439000eb772272745c344f5257f3ecce369c0
>> # Parent  18ff26b2cb10286556b57cc580bb4e76d84c5c10
>> # EXP-Topic discovery-refactor
>> # Available At https://bitbucket.org/octobus/mercurial-devel/
>> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r
>> f3c439000eb7
>> discovery: move common heads computation inside partialdiscovery object
>>
>> This remove one of the private attribute access. In additions, head
>> tracking
>> and computation is a typical operation we can speed up using Rust.
>>
>
Queued 3-4 i.e. upto here. Many thanks!

(Sorry for queueing in parts, it's taking me time to understand the code
around)

Patch

diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py
+++ b/mercurial/setdiscovery.py
@@ -182,6 +182,10 @@  class partialdiscovery(object):
         """return True is we have any clue about the remote state"""
         return self._common.hasbases()
 
+    def commonheads(self):
+        """the heads of the known common set"""
+        return set(self._repo.revs('heads(%ld)',
+                   self._common.bases - {nullrev}))
 
 def findcommonheads(ui, local, remote,
                     initialsamplesize=100,
@@ -314,7 +318,7 @@  def findcommonheads(ui, local, remote,
     # 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.
-    result = set(local.revs('heads(%ld)', disco._common.bases - {nullrev}))
+    result = disco.commonheads()
     elapsed = util.timer() - start
     progress.complete()
     ui.debug("%d total queries in %.4fs\n" % (roundtrips, elapsed))