equal
deleted
inserted
replaced
286 |
286 |
287 def _make_uid(): |
287 def _make_uid(): |
288 """return a new unique identifier. |
288 """return a new unique identifier. |
289 |
289 |
290 The identifier is random and composed of ascii characters.""" |
290 The identifier is random and composed of ascii characters.""" |
291 return hex(os.urandom(ID_SIZE)) |
291 # size we "hex" the result we need half the number of bits to have a final |
|
292 # uuid of size ID_SIZE |
|
293 return hex(os.urandom(ID_SIZE // 2)) |
292 |
294 |
293 |
295 |
294 # some special test logic to avoid anoying random output in the test |
296 # some special test logic to avoid anoying random output in the test |
295 stable_docket_file = encoding.environ.get(b'HGTEST_DOCKETIDFILE') |
297 stable_docket_file = encoding.environ.get(b'HGTEST_DOCKETIDFILE') |
296 |
298 |
319 if pycompat.ispy3: |
321 if pycompat.ispy3: |
320 r.seed(int_seed, version=1) |
322 r.seed(int_seed, version=1) |
321 else: |
323 else: |
322 r.seed(int_seed) |
324 r.seed(int_seed) |
323 # once we drop python 3.8 support we can simply use r.randbytes |
325 # once we drop python 3.8 support we can simply use r.randbytes |
324 raw = r.getrandbits(ID_SIZE * 8) |
326 raw = r.getrandbits(ID_SIZE * 4) |
325 assert ID_SIZE == 8 |
327 assert ID_SIZE == 8 |
326 p = struct.pack('>Q', raw) |
328 p = struct.pack('>L', raw) |
327 new = hex(p) |
329 new = hex(p) |
328 with open(stable_docket_file, 'wb') as f: |
330 with open(stable_docket_file, 'wb') as f: |
329 f.write(new) |
331 f.write(new) |
330 return new |
332 return new |
331 |
333 |