python-compat: adapt to Python 3.11 BC breakage with `random.sample`
As per https://docs.python.org/3/whatsnew/3.11.html#porting-to-python-3-11:
"The population parameter of `random.sample()` must be a sequence, and
automatic conversion of sets to lists is no longer supported.
Also, if the sample size is larger than the population size,
a `ValueError` is raised"
--- a/mercurial/setdiscovery.py Tue Nov 22 11:55:26 2022 -0500
+++ b/mercurial/setdiscovery.py Wed Nov 23 14:42:11 2022 +0100
@@ -99,9 +99,9 @@
"""
if len(sample) <= desiredlen:
return sample
+ sample = list(sample)
if randomize:
return set(random.sample(sample, desiredlen))
- sample = list(sample)
sample.sort()
return set(sample[:desiredlen])