changeset 49640:76c128d4de4e stable

revset: the `random` sort should not depend on sys.maxsize (issue6770)
author Julien Cristau <jcristau@mozilla.com>
date Tue, 06 Dec 2022 15:11:51 +0100
parents d00ac86fbd78
children 43bfddcba7d6
files mercurial/revset.py tests/test-revset.t
diffstat 2 files changed, 7 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revset.py	Mon Jan 23 14:04:17 2023 +0100
+++ b/mercurial/revset.py	Tue Dec 06 15:11:51 2022 +0100
@@ -10,7 +10,6 @@
 import functools
 import random
 import re
-import sys
 
 from .i18n import _
 from .pycompat import getattr
@@ -2355,7 +2354,7 @@
     return subset & s.filter(filter, condrepr=b'<roots>')
 
 
-MAXINT = sys.maxsize
+MAXINT = (1 << 31) - 1
 MININT = -MAXINT - 1
 
 
--- a/tests/test-revset.t	Mon Jan 23 14:04:17 2023 +0100
+++ b/tests/test-revset.t	Tue Dec 06 15:11:51 2022 +0100
@@ -2981,16 +2981,16 @@
   $ hg log --rev 'sort(all(), "-random")' | wc -l
   \s*8 (re)
   $ hg log --rev 'sort(all(), "random", random.seed=celeste)'
+  0 b12  m111 u112 111 10800
+  4 b111 m112 u111 110 14400
+  2 b111 m11  u12  111 3600
   6 b111 t2   tu   130 0
+  1 b11  m12  u111 112 7200
   7 b111 t3   tu   130 0
-  4 b111 m112 u111 110 14400
-  3 b112 m111 u11  120 0
   5 b111 t1   tu   130 0
+  3 b112 m111 u11  120 0
+  $ hg log --rev 'first(sort(all(), "random", random.seed=celeste))'
   0 b12  m111 u112 111 10800
-  1 b11  m12  u111 112 7200
-  2 b111 m11  u12  111 3600
-  $ hg log --rev 'first(sort(all(), "random", random.seed=celeste))'
-  6 b111 t2   tu   130 0
 
 
 topographical sorting can't be combined with other sort keys, and you can't