D3145: context: catch right exceptions from namespace lookup (API)

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Thu Apr 5 22:07:32 UTC 2018


martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Similar to the previous patch, here we were catching
  FilteredRepoLookupError and RepoLookupError instead of
  FilteredLookupError and LookupError. What makes this trickier is that
  this is calling into namespaces code, and since namespaces are meant
  to be extensible, we could potentially get a RepoLookupError from the
  namespace lookup. If we got a RepoLookupError before, we would swallow
  it and try to interpret the string as a partial nodeid. That means
  that if the user runs `hg co deadbeef` where "deadbeef" is a valid
  nodeid prefix and also something that make some namespace raise a
  RepoLookupError, we would happily check out the requested
  revision. After this patch, we will instead error out.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/context.py

CHANGE DETAILS

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -449,9 +449,9 @@
                 return
             except KeyError:
                 pass
-            except error.FilteredRepoLookupError:
+            except error.FilteredLookupError:
                 raise
-            except error.RepoLookupError:
+            except error.LookupError:
                 pass
 
             self._node = repo.unfiltered().changelog._partialmatch(changeid)



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


More information about the Mercurial-devel mailing list