py3-discovery: using plain str in stats dict
authorGeorges Racinet <georges.racinet@octobus.net>
Thu, 10 Oct 2019 11:33:33 +0200
changeset 43162 3c6976b1f693
parent 43161 9d57c2df7b5f
child 43163 5617b748aad8
py3-discovery: using plain str in stats dict rust-cpython converts automatically from Rust strings to the appropriate `str` for the target Python version. Insisting on discovery stats dict keys to be bytes hence breaks the process (this is spotted by test-setdiscovery.t). Now that byteify-strings has been run on the entire codebase, and the import transformer is not there any more, the simplest fix is to make the keys plain str again. Another possible fix would be to forcefully convert to bytes in rust-cpython code, but that feels less natural, and would probably have to be reverted down the road. Differential Revision: https://phab.mercurial-scm.org/D7039
mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py	Thu Oct 10 04:48:31 2019 +0200
+++ b/mercurial/setdiscovery.py	Thu Oct 10 11:33:33 2019 +0200
@@ -176,7 +176,7 @@
 
     def stats(self):
         return {
-            b'undecided': len(self.undecided),
+            'undecided': len(self.undecided),
         }
 
     def commonheads(self):
@@ -441,7 +441,7 @@
         stats = disco.stats()
         ui.debug(
             b"query %i; still undecided: %i, sample size is: %i\n"
-            % (roundtrips, stats[b'undecided'], len(sample))
+            % (roundtrips, stats['undecided'], len(sample))
         )
 
         # indices between sample and externalized version must match