Patchwork [3,of,6] repoview: add a FilteredIndexError class

login
register
mail settings
Submitter Pierre-Yves David
Date Oct. 16, 2014, 9:30 a.m.
Message ID <2dabd90d3490e271f164.1413451808@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/6325/
State Accepted
Headers show

Comments

Pierre-Yves David - Oct. 16, 2014, 9:30 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1413417764 25200
#      Wed Oct 15 17:02:44 2014 -0700
# Node ID 2dabd90d3490e271f164a8992b86550dc3e0dfd3
# Parent  1e638fa45fbcdaa23e1b89f6be9cd1658adf62a3
repoview: add a FilteredIndexError class

This exception is a more precise IndexError that will allow us to issue special
message when we end up accessing a filtered revision.

Patch

diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -194,29 +194,29 @@  class changelog(revlog.revlog):
         return r
 
     def node(self, rev):
         """filtered version of revlog.node"""
         if rev in self.filteredrevs:
-            raise IndexError(rev)
+            raise error.FilteredIndexError(rev)
         return super(changelog, self).node(rev)
 
     def linkrev(self, rev):
         """filtered version of revlog.linkrev"""
         if rev in self.filteredrevs:
-            raise IndexError(rev)
+            raise error.FilteredIndexError(rev)
         return super(changelog, self).linkrev(rev)
 
     def parentrevs(self, rev):
         """filtered version of revlog.parentrevs"""
         if rev in self.filteredrevs:
-            raise IndexError(rev)
+            raise error.FilteredIndexError(rev)
         return super(changelog, self).parentrevs(rev)
 
     def flags(self, rev):
         """filtered version of revlog.flags"""
         if rev in self.filteredrevs:
-            raise IndexError(rev)
+            raise error.FilteredIndexError(rev)
         return super(changelog, self).flags(rev)
 
     def delayupdate(self):
         "delay visibility of index updates to other readers"
         self._delayed = True
diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -14,10 +14,13 @@  imports.
 # Do not import anything here, please
 
 class RevlogError(Exception):
     pass
 
+class FilteredIndexError(IndexError):
+    pass
+
 class LookupError(RevlogError, KeyError):
     def __init__(self, name, index, message):
         self.name = name
         if isinstance(name, str) and len(name) == 20:
             from node import short