[PATCH STABLE] context: translate FilteredIndex/LookupError at repo[changeid] (API)

Yuya Nishihara yuya at tcha.org
Thu Apr 19 11:25:34 UTC 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1524135351 -32400
#      Thu Apr 19 19:55:51 2018 +0900
# Branch stable
# Node ID 8ba1c6dab49f5665dc687000f149eb530a1079cf
# Parent  8cde3d58cdc88707dd61a24fdccf229e2ac83610
context: translate FilteredIndex/LookupError at repo[changeid] (API)

This partially backs out ecd3f6909184. It seems layering violation for
repo[changeid] to raise storage-level exceptions transparently. Otherwise,
we would have to rewrite callers to catch all of them.

  try:
      repo[rev_or_node]
  except (error.RepoLookupError, error.FilteredIndexError,
          error.FilteredLookupError):
      pass

This would also fix filectx._changectx(), which catches FilteredRepoLookupError
to fall back to the unfiltered path.

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -497,8 +497,10 @@ class changectx(basectx):
                     changeid = hex(changeid)
             except TypeError:
                 pass
-        except (error.FilteredIndexError, error.FilteredLookupError,
-                error.FilteredRepoLookupError):
+        except (error.FilteredIndexError, error.FilteredLookupError):
+            raise error.FilteredRepoLookupError(_("filtered revision '%s'")
+                                                % changeid)
+        except error.FilteredRepoLookupError:
             raise
         except IndexError:
             pass
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -850,8 +850,7 @@ class localrepository(object):
         try:
             self[changeid]
             return True
-        except (error.RepoLookupError, error.FilteredIndexError,
-                error.FilteredLookupError):
+        except error.RepoLookupError:
             return False
 
     def __nonzero__(self):


More information about the Mercurial-devel mailing list