Mercurial > hg
comparison mercurial/revlogutils/docket.py @ 48909:0aae0e2e90fc
revlogutils: unconditionally pass version to random seed
Differential Revision: https://phab.mercurial-scm.org/D12312
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 01 Mar 2022 20:37:09 -0800 |
parents | ed2af4560f6e |
children | 642e31cb55f0 |
comparison
equal
deleted
inserted
replaced
48908:ed2af4560f6e | 48909:0aae0e2e90fc |
---|---|
23 | 23 |
24 from .. import ( | 24 from .. import ( |
25 encoding, | 25 encoding, |
26 error, | 26 error, |
27 node, | 27 node, |
28 pycompat, | |
29 util, | 28 util, |
30 ) | 29 ) |
31 | 30 |
32 from . import ( | 31 from . import ( |
33 constants, | 32 constants, |
63 for i in iter_seed: | 62 for i in iter_seed: |
64 high_part = int_seed >> 35 | 63 high_part = int_seed >> 35 |
65 low_part = (int_seed & low_mask) << 28 | 64 low_part = (int_seed & low_mask) << 28 |
66 int_seed = high_part + low_part + i | 65 int_seed = high_part + low_part + i |
67 r = random.Random() | 66 r = random.Random() |
68 if pycompat.ispy3: | 67 r.seed(int_seed, version=1) |
69 r.seed(int_seed, version=1) | |
70 else: | |
71 r.seed(int_seed) | |
72 # once we drop python 3.8 support we can simply use r.randbytes | 68 # once we drop python 3.8 support we can simply use r.randbytes |
73 raw = r.getrandbits(id_size * 4) | 69 raw = r.getrandbits(id_size * 4) |
74 assert id_size == 8 | 70 assert id_size == 8 |
75 p = struct.pack('>L', raw) | 71 p = struct.pack('>L', raw) |
76 new = node.hex(p) | 72 new = node.hex(p) |