Patchwork [7,of,8] discovery: move missing tracking inside the partialdiscovery object

login
register
mail settings
Submitter Boris Feld
Date Dec. 31, 2018, 5:35 p.m.
Message ID <c5c3e376d7afcb5972f7.1546277754@Laptop-Boris.lan>
Download mbox | patch
Permalink /patch/37411/
State Superseded
Headers show

Comments

Boris Feld - Dec. 31, 2018, 5:35 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1545965280 -3600
#      Fri Dec 28 03:48:00 2018 +0100
# Node ID c5c3e376d7afcb5972f72262d84b6d4b75645329
# Parent  b1294a6cb1b4c1d30ef9840bf023b95337603158
# EXP-Topic discovery-refactor
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r c5c3e376d7af
discovery: move missing tracking inside the partialdiscovery object

This is the final set that we need to track to have a fully up to date
information within the object.
Pulkit Goyal - Jan. 4, 2019, 4:05 p.m.
On Mon, Dec 31, 2018 at 11:18 PM Boris Feld <boris.feld@octobus.net> wrote:

> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1545965280 -3600
> #      Fri Dec 28 03:48:00 2018 +0100
> # Node ID c5c3e376d7afcb5972f72262d84b6d4b75645329
> # Parent  b1294a6cb1b4c1d30ef9840bf023b95337603158
> # EXP-Topic discovery-refactor
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r
> c5c3e376d7af
> discovery: move missing tracking inside the partialdiscovery object
>
> This is the final set that we need to track to have a fully up to date
> information within the object.
>
> diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
> --- a/mercurial/setdiscovery.py
> +++ b/mercurial/setdiscovery.py
> @@ -170,6 +170,7 @@ class partialdiscovery(object):
>      - common: exist both locally and remotely
>      - common:    own nodes I know we both know
>      - undecided: own nodes where I don't know if remote knows them
> +    - missing:   own nodes I know remote lacks
>      """
>
same, can you replace "I" and "own" with better words, maybe local
Boris Feld - Jan. 4, 2019, 5:28 p.m.
On 04/01/2019 17:05, Pulkit Goyal wrote:
>
>
> On Mon, Dec 31, 2018 at 11:18 PM Boris Feld <boris.feld@octobus.net
> <mailto:boris.feld@octobus.net>> wrote:
>
>     # HG changeset patch
>     # User Boris Feld <boris.feld@octobus.net
>     <mailto:boris.feld@octobus.net>>
>     # Date 1545965280 -3600
>     #      Fri Dec 28 03:48:00 2018 +0100
>     # Node ID c5c3e376d7afcb5972f72262d84b6d4b75645329
>     # Parent  b1294a6cb1b4c1d30ef9840bf023b95337603158
>     # EXP-Topic discovery-refactor
>     # Available At https://bitbucket.org/octobus/mercurial-devel/
>     #              hg pull
>     https://bitbucket.org/octobus/mercurial-devel/ -r c5c3e376d7af
>     discovery: move missing tracking inside the partialdiscovery object
>
>     This is the final set that we need to track to have a fully up to date
>     information within the object.
>
>     diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
>     --- a/mercurial/setdiscovery.py
>     +++ b/mercurial/setdiscovery.py
>     @@ -170,6 +170,7 @@ class partialdiscovery(object):
>          - common: exist both locally and remotely
>          - common:    own nodes I know we both know
>          - undecided: own nodes where I don't know if remote knows them
>     +    - missing:   own nodes I know remote lacks
>          """
>
> same, can you replace "I" and "own" with better words, maybe local
Same here, are you okay with a documentation follow up?
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py
+++ b/mercurial/setdiscovery.py
@@ -170,6 +170,7 @@  class partialdiscovery(object):
     - common: exist both locally and remotely
     - common:    own nodes I know we both know
     - undecided: own nodes where I don't know if remote knows them
+    - missing:   own nodes I know remote lacks
     """
 
     def __init__(self, repo, targetheads):
@@ -177,12 +178,24 @@  class partialdiscovery(object):
         self._targetheads = targetheads
         self._common = repo.changelog.incrementalmissingrevs()
         self._undecided = None
+        self.missing = set()
 
     def addcommons(self, commons):
         """registrer nodes known as common"""
         self._common.addbases(commons)
         self._common.removeancestorsfrom(self.undecided)
 
+    def addmissings(self, missings):
+        """registrer some nodes as missing"""
+        if self.missing:
+            new = self._repo.revs('descendants(%ld) - descendants(%ld)',
+                                  missings, self.missing)
+            self.missing.update(new)
+        else:
+            self.missing.update(self._repo.revs('descendants(%ld)', missings))
+
+        self.undecided.difference_update(self.missing)
+
     def hasinfo(self):
         """return True is we have any clue about the remote state"""
         return self._common.hasbases()
@@ -275,8 +288,6 @@  def findcommonheads(ui, local, remote,
     disco.addcommons(srvheads)
     commoninsample = set(n for i, n in enumerate(sample) if yesno[i])
     disco.addcommons(commoninsample)
-    # own nodes I know remote lacks
-    missing = set()
 
     full = False
     progress = ui.makeprogress(_('searching'), unit=_('queries'))
@@ -284,14 +295,8 @@  def findcommonheads(ui, local, remote,
 
         if sample:
             missinginsample = [n for i, n in enumerate(sample) if not yesno[i]]
+            disco.addmissings(missinginsample)
 
-            if missing:
-                missing.update(local.revs('descendants(%ld) - descendants(%ld)',
-                                          missinginsample, missing))
-            else:
-                missing.update(local.revs('descendants(%ld)', missinginsample))
-
-            disco.undecided.difference_update(missing)
 
         if disco.iscomplete():
             break