comparison mercurial/branching/rev_cache.py @ 52640:24ee91ba9aa8

pyupgrade: drop usage of py3 aliases for `OSError` These were different classes in py2, but now a handful of error classes are just an alias of `OSError`, like `IOError`, `EnvironmentError`, `WindowsError`, etc. This is the result of running a hacked version of `pyupgrade` 3.19.1[1] $ hg files -0 'relglob:**.py' | xargs -0 \ pyupgrade --py38-plus --keep-percent-format --keep-mock --keep-runtime-typing The hack is because it doesn't have command line switches to disable most changes, so it makes tons of unrelated changes all at once. The hack is to 1) patch `pyupgrade._main._fix_tokens()` to immediately return its content arg 2) change `pyupgrade._data.register_decorator()` to only register the function if it's from the fixer we're interested in: if func.__module__ in ( "pyupgrade._plugins.exceptions", ): FUNCS[tp].append(func) return func [1] https://github.com/asottile/pyupgrade
author Matt Harbison <matt_harbison@yahoo.com>
date Sun, 05 Jan 2025 21:03:17 -0500
parents db1980a361cb
children
comparison
equal deleted inserted replaced
52639:9db77d46de79 52640:24ee91ba9aa8
155 self._force_overwrite = False 155 self._force_overwrite = False
156 v1_fallback = False 156 v1_fallback = False
157 try: 157 try:
158 try: 158 try:
159 bndata = repo.cachevfs.read(_rbcnames) 159 bndata = repo.cachevfs.read(_rbcnames)
160 except (IOError, OSError): 160 except OSError:
161 # If we don't have "v2" data, we might have "v1" data worth 161 # If we don't have "v2" data, we might have "v1" data worth
162 # using. 162 # using.
163 # 163 #
164 # consider stop doing this many version after hg-6.9 release 164 # consider stop doing this many version after hg-6.9 release
165 bndata = repo.cachevfs.read(_rbc_legacy_names) 165 bndata = repo.cachevfs.read(_rbc_legacy_names)
168 self._rbcsnameslen = len(bndata) # for verification before writing 168 self._rbcsnameslen = len(bndata) # for verification before writing
169 if bndata: 169 if bndata:
170 self._names = [ 170 self._names = [
171 encoding.tolocal(bn) for bn in bndata.split(b'\0') 171 encoding.tolocal(bn) for bn in bndata.split(b'\0')
172 ] 172 ]
173 except (IOError, OSError): 173 except OSError:
174 if readonly: 174 if readonly:
175 # don't try to use cache - fall back to the slow path 175 # don't try to use cache - fall back to the slow path
176 self.branchinfo = self._branchinfo 176 self.branchinfo = self._branchinfo
177 177
178 if self._names: 178 if self._names:
203 # Consider stop doing this many version after hg-6.9 203 # Consider stop doing this many version after hg-6.9
204 # release. 204 # release.
205 with repo.cachevfs(_rbc_legacy_revs) as fp: 205 with repo.cachevfs(_rbc_legacy_revs) as fp:
206 data = fp.read() 206 data = fp.read()
207 self._rbcrevs = rbcrevs(data) 207 self._rbcrevs = rbcrevs(data)
208 except (IOError, OSError) as inst: 208 except OSError as inst:
209 repo.ui.debug( 209 repo.ui.debug(
210 b"couldn't read revision branch cache: %s\n" 210 b"couldn't read revision branch cache: %s\n"
211 % stringutil.forcebytestr(inst) 211 % stringutil.forcebytestr(inst)
212 ) 212 )
213 # remember number of good records on disk 213 # remember number of good records on disk
350 step = b'' 350 step = b''
351 if wlock is None: 351 if wlock is None:
352 wlock = repo.wlock(wait=False) 352 wlock = repo.wlock(wait=False)
353 self._writerevs(repo, start) 353 self._writerevs(repo, start)
354 354
355 except (IOError, OSError, error.Abort, error.LockError) as inst: 355 except (OSError, error.Abort, error.LockError) as inst:
356 repo.ui.debug( 356 repo.ui.debug(
357 b"couldn't write revision branch cache%s: %s\n" 357 b"couldn't write revision branch cache%s: %s\n"
358 % (step, stringutil.forcebytestr(inst)) 358 % (step, stringutil.forcebytestr(inst))
359 ) 359 )
360 finally: 360 finally: