# HG changeset patch # User Pierre-Yves David # Date 2019-12-11 16:35:29 # Node ID f2de8dc9c52f5c9ea557efaabd6b8ed2a3b997ad # Parent c41ed5d4f77025d883e87f1fb5b21f38476cb49e 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 diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -545,12 +545,10 @@ def shortesthexnodeidprefix(repo, node, if cache is not None: nodetree = cache.get(b'disambiguationnodetree') if not nodetree: - try: + if util.safehasattr(parsers, 'nodetree'): + # The CExt is the only implementation to provide a nodetree + # class so far. nodetree = parsers.nodetree(cl.index, len(revs)) - except AttributeError: - # no native nodetree - pass - else: for r in revs: nodetree.insert(r) if cache is not None: