Patchwork ["] discovery: clarify why the caching of children is valid

login
register
mail settings
Submitter Pierre-Yves David
Date March 7, 2019, 12:50 a.m.
Message ID <b8c0855a41e76a76fcef.1551919816@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/39116/
State Accepted
Headers show

Comments

Pierre-Yves David - March 7, 2019, 12:50 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1551918504 -3600
#      Thu Mar 07 01:28:24 2019 +0100
# Node ID b8c0855a41e76a76fcef367b75ad3b1844685428
# Parent  a05f0bbefdd961409bf77120a0f71d4ad8332785
# EXP-Topic discovery
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r b8c0855a41e7
discovery: clarify why the caching of children is valid

Yuya Nishihara pointed out that the code looks wrong without this clarification.
(And, unsurprisingly, Yuya is right)
Yuya Nishihara - March 7, 2019, 10:47 p.m.
On Thu, 07 Mar 2019 01:50:16 +0100, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@octobus.net>
> # Date 1551918504 -3600
> #      Thu Mar 07 01:28:24 2019 +0100
> # Node ID b8c0855a41e76a76fcef367b75ad3b1844685428
> # Parent  a05f0bbefdd961409bf77120a0f71d4ad8332785
> # EXP-Topic discovery
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r b8c0855a41e7
> discovery: clarify why the caching of children is valid

Queued, thanks.

Patch

diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py
+++ b/mercurial/setdiscovery.py
@@ -175,6 +175,10 @@  class partialdiscovery(object):
     def _childrengetter(self):
 
         if self._childrenmap is not None:
+            # During discovery, the `undecided` set keep shrinking.
+            # Therefore, the map computed for an iteration N will be
+            # valid for iteration N+1. Instead of computing the same
+            # data over and over we cached it the first time.
             return self._childrenmap.__getitem__
 
         # _updatesample() essentially does interaction over revisions to look