Patchwork D7039: py3-discovery: using plain str in stats dict

login
register
mail settings
Submitter phabricator
Date Oct. 10, 2019, 9:50 a.m.
Message ID <differential-rev-PHID-DREV-si4oso2ribzqnkuiqbmi-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/42181/
State Superseded
Headers show

Comments

phabricator - Oct. 10, 2019, 9:50 a.m.
gracinet created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D7039

AFFECTED FILES
  mercurial/setdiscovery.py

CHANGE DETAILS




To: gracinet, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py
+++ b/mercurial/setdiscovery.py
@@ -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