changeset 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 c41ed5d4f770
children a89381e04c58
files mercurial/scmutil.py
diffstat 1 files changed, 3 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/scmutil.py	Wed Dec 11 15:06:09 2019 -0800
+++ b/mercurial/scmutil.py	Wed Dec 11 17:35:29 2019 +0100
@@ -545,12 +545,10 @@
             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: