comparison hgext/fastannotate/commands.py @ 50951:d718eddf01d9

safehasattr: drop usage in favor of hasattr The two functions should now be equivalent at least in their usage in core.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 31 Aug 2023 23:56:15 +0200
parents 6000f5b25c9b
children 45d5e9a0f6a6
comparison
equal deleted inserted replaced
50950:7a8ea1397816 50951:d718eddf01d9
17 logcmdutil, 17 logcmdutil,
18 patch, 18 patch,
19 pycompat, 19 pycompat,
20 registrar, 20 registrar,
21 scmutil, 21 scmutil,
22 util,
23 ) 22 )
24 23
25 from . import ( 24 from . import (
26 context as facontext, 25 context as facontext,
27 error as faerror, 26 error as faerror,
216 215
217 # paths will be used for prefetching and the real annotating 216 # paths will be used for prefetching and the real annotating
218 paths = list(_matchpaths(repo, rev, pats, opts, aopts)) 217 paths = list(_matchpaths(repo, rev, pats, opts, aopts))
219 218
220 # for client, prefetch from the server 219 # for client, prefetch from the server
221 if util.safehasattr(repo, 'prefetchfastannotate'): 220 if hasattr(repo, 'prefetchfastannotate'):
222 repo.prefetchfastannotate(paths) 221 repo.prefetchfastannotate(paths)
223 222
224 for path in paths: 223 for path in paths:
225 result = lines = existinglines = None 224 result = lines = existinglines = None
226 while True: 225 while True:
271 if ui.configbool(b'fastannotate', b'forcetext'): 270 if ui.configbool(b'fastannotate', b'forcetext'):
272 opts['text'] = True 271 opts['text'] = True
273 272
274 # check if we need to do prefetch (client-side) 273 # check if we need to do prefetch (client-side)
275 rev = opts.get('rev') 274 rev = opts.get('rev')
276 if util.safehasattr(repo, 'prefetchfastannotate') and rev is not None: 275 if hasattr(repo, 'prefetchfastannotate') and rev is not None:
277 paths = list(_matchpaths(repo, rev, pats, pycompat.byteskwargs(opts))) 276 paths = list(_matchpaths(repo, rev, pats, pycompat.byteskwargs(opts)))
278 repo.prefetchfastannotate(paths) 277 repo.prefetchfastannotate(paths)
279 278
280 return orig(ui, repo, *pats, **opts) 279 return orig(ui, repo, *pats, **opts)
281 280
318 if ui.configbool(b'fastannotate', b'unfilteredrepo'): 317 if ui.configbool(b'fastannotate', b'unfilteredrepo'):
319 repo = repo.unfiltered() 318 repo = repo.unfiltered()
320 ctx = logcmdutil.revsingle(repo, rev) 319 ctx = logcmdutil.revsingle(repo, rev)
321 m = scmutil.match(ctx, pats, opts) 320 m = scmutil.match(ctx, pats, opts)
322 paths = list(ctx.walk(m)) 321 paths = list(ctx.walk(m))
323 if util.safehasattr(repo, 'prefetchfastannotate'): 322 if hasattr(repo, 'prefetchfastannotate'):
324 # client 323 # client
325 if opts.get(b'REV'): 324 if opts.get(b'REV'):
326 raise error.Abort(_(b'--rev cannot be used for client')) 325 raise error.Abort(_(b'--rev cannot be used for client'))
327 repo.prefetchfastannotate(paths) 326 repo.prefetchfastannotate(paths)
328 else: 327 else: