comparison contrib/perf.py @ 29494:3b5389ef5cfe

perf: define util.safehasattr forcibly for Mercurial earlier than 1.9.3 Before this patch, using util.safehasattr() prevents perf.py from being loaded by Mercurial earlier than 1.9.3 (or 94b200a11cf7), because util.safehasattr() isn't available in such Mercurial, even though there are some code paths for Mercurial earlier than 1.9.3. For example, setting "_prereadsize" attribute in perfindex() and perfnodelookup() is effective only with Mercurial earlier than 1.8 (or 61c9bc3da402). This patch is a preparation for using util.safehasattr() safely in subsequent patches. This patch defines util.safehasattr() forcibly without examining whether it is available or not, because: - examining existence of "safehasattr" safely itself needs similar logic - safehasattr() is small enough to define locally
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Tue, 05 Jul 2016 07:25:51 +0900
parents 4533f5b47949
children f83445296213
comparison
equal deleted inserted replaced
29493:4533f5b47949 29494:3b5389ef5cfe
36 repoview, 36 repoview,
37 revlog, 37 revlog,
38 scmutil, 38 scmutil,
39 util, 39 util,
40 ) 40 )
41
42 # for "historical portability":
43 # define util.safehasattr forcibly, because util.safehasattr has been
44 # available since 1.9.3 (or 94b200a11cf7)
45 _undefined = object()
46 def safehasattr(thing, attr):
47 return getattr(thing, attr, _undefined) is not _undefined
48 setattr(util, 'safehasattr', safehasattr)
41 49
42 formatteropts = commands.formatteropts 50 formatteropts = commands.formatteropts
43 revlogopts = commands.debugrevlogopts 51 revlogopts = commands.debugrevlogopts
44 52
45 cmdtable = {} 53 cmdtable = {}