Patchwork D7651: nodetree: simplify a conditionnal in shortesthexnodeidprefix

login
register
mail settings
Submitter phabricator
Date Dec. 13, 2019, 8:11 p.m.
Message ID <differential-rev-PHID-DREV-ybrpawuwt5cd3ia57w3i-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/43808/
State Superseded
Headers show

Comments

phabricator - Dec. 13, 2019, 8:11 p.m.
marmoute created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D7651

AFFECTED FILES
  mercurial/scmutil.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -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: