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

Pierre-Yves David pierre-yves.david at ens-lyon.org
Wed Mar 6 19:50:16 EST 2019


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at 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)

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


More information about the Mercurial-devel mailing list