[PATCH] discovery: stop direct use of attribute of partialdiscovery

Georges Racinet georges.racinet at octobus.net
Thu Apr 11 17:42:29 UTC 2019


# HG changeset patch
# User Georges Racinet <georges.racinet at octobus.net>
# Date 1554999007 -7200
#      Thu Apr 11 18:10:07 2019 +0200
# Node ID 44c5e57b870d6ca9e93a5ff289caf3e0c0e90853
# Parent  509a0477b3a6e9f1ea0fe32bfb028c256aada7fa
# EXP-Topic rust-discovery
discovery: stop direct use of attribute of partialdiscovery

Instead of accessing `undecided` directly for ui display purposes,
we introduce a `stats()` method that could be extended in the future with
more interesting information.

This is in preparation for a forthcoming Rust version of this object.
Indeed, attributes and furthermore properties are a bit complicated for
classes in native code.

We could go further and rename `undecided` to mark it private, but `_undecided`
is already taken as support for `_undecided` lazyness.

diff -r 509a0477b3a6 -r 44c5e57b870d mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py	Tue Apr 09 21:59:37 2019 +0900
+++ b/mercurial/setdiscovery.py	Thu Apr 11 18:10:07 2019 +0200
@@ -160,6 +160,11 @@
         self._undecided = set(self._common.missingancestors(self._targetheads))
         return self._undecided
 
+    def stats(self):
+        return {
+            'undecided': len(self.undecided),
+        }
+
     def commonheads(self):
         """the heads of the known common set"""
         # heads(common) == heads(common.bases) since common represents
@@ -339,8 +344,10 @@
 
         roundtrips += 1
         progress.update(roundtrips)
+        stats = disco.stats()
         ui.debug("query %i; still undecided: %i, sample size is: %i\n"
-                 % (roundtrips, len(disco.undecided), len(sample)))
+                 % (roundtrips, stats['undecided'], len(sample)))
+
         # indices between sample and externalized version must match
         sample = list(sample)
 


More information about the Mercurial-devel mailing list