discovery: stop direct use of attribute of partialdiscovery
authorGeorges Racinet <georges.racinet@octobus.net>
Thu, 11 Apr 2019 18:10:07 +0200
changeset 42103 362726923ba3
parent 42102 976f069e0ad6
child 42104 4b86f4f199a9
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.
mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py	Wed Apr 10 17:36:37 2019 -0700
+++ 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)