comparison mercurial/scmutil.py @ 43911:f2de8dc9c52f

nodetree: simplify a conditionnal in shortesthexnodeidprefix instead of try to catch some attribute error, we could just nicely look if the attribute will be available. This make the code simpler to follow and less error prone since we no longer rely on a wider attribute catching. Differential Revision: https://phab.mercurial-scm.org/D7651
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 11 Dec 2019 17:35:29 +0100
parents b5f183eedd98
children 60de488cad11
comparison
equal deleted inserted replaced
43910:c41ed5d4f770 43911:f2de8dc9c52f
543 hexnode = hex(node) 543 hexnode = hex(node)
544 nodetree = None 544 nodetree = None
545 if cache is not None: 545 if cache is not None:
546 nodetree = cache.get(b'disambiguationnodetree') 546 nodetree = cache.get(b'disambiguationnodetree')
547 if not nodetree: 547 if not nodetree:
548 try: 548 if util.safehasattr(parsers, 'nodetree'):
549 # The CExt is the only implementation to provide a nodetree
550 # class so far.
549 nodetree = parsers.nodetree(cl.index, len(revs)) 551 nodetree = parsers.nodetree(cl.index, len(revs))
550 except AttributeError:
551 # no native nodetree
552 pass
553 else:
554 for r in revs: 552 for r in revs:
555 nodetree.insert(r) 553 nodetree.insert(r)
556 if cache is not None: 554 if cache is not None:
557 cache[b'disambiguationnodetree'] = nodetree 555 cache[b'disambiguationnodetree'] = nodetree
558 if nodetree is not None: 556 if nodetree is not None: