Patchwork discovery: stop direct use of attribute of partialdiscovery

login
register
mail settings
Submitter Georges Racinet
Date April 11, 2019, 5:42 p.m.
Message ID <44c5e57b870d6ca9e93a.1555004549@purity.tombe.racinet.fr>
Download mbox | patch
Permalink /patch/39558/
State Accepted
Headers show

Comments

Georges Racinet - April 11, 2019, 5:42 p.m.
# HG changeset patch
# User Georges Racinet <georges.racinet@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.
Pulkit Goyal - April 12, 2019, 12:30 p.m.
On Thu, Apr 11, 2019 at 9:18 PM Georges Racinet <georges.racinet@octobus.net>
wrote:

> # HG changeset patch
> # User Georges Racinet <georges.racinet@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.
>

Queued this, many thanks!

Patch

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)