comparison mercurial/revlogutils/docket.py @ 49314:2e726c934fcd

py3: catch FileNotFoundError instead of checking errno == ENOENT
author Manuel Jacob <me@manueljacob.de>
date Tue, 31 May 2022 22:50:01 +0200
parents 642e31cb55f0
children f04d459909c6
comparison
equal deleted inserted replaced
49313:53e9422a9b45 49314:2e726c934fcd
14 # * an index file, containing fixed width information about revisions, 14 # * an index file, containing fixed width information about revisions,
15 # 15 #
16 # * a data file, containing variable width data for these revisions, 16 # * a data file, containing variable width data for these revisions,
17 17
18 18
19 import errno
20 import os 19 import os
21 import random 20 import random
22 import struct 21 import struct
23 22
24 from .. import ( 23 from .. import (
49 48
50 def make_uid(id_size=8): 49 def make_uid(id_size=8):
51 try: 50 try:
52 with open(stable_docket_file, mode='rb') as f: 51 with open(stable_docket_file, mode='rb') as f:
53 seed = f.read().strip() 52 seed = f.read().strip()
54 except IOError as inst: 53 except FileNotFoundError:
55 if inst.errno != errno.ENOENT:
56 raise
57 seed = b'04' # chosen by a fair dice roll. garanteed to be random 54 seed = b'04' # chosen by a fair dice roll. garanteed to be random
58 iter_seed = iter(seed) 55 iter_seed = iter(seed)
59 # some basic circular sum hashing on 64 bits 56 # some basic circular sum hashing on 64 bits
60 int_seed = 0 57 int_seed = 0
61 low_mask = int('1' * 35, 2) 58 low_mask = int('1' * 35, 2)