Patchwork [4,of,6] repoview: add a FilteredLookupError class

login
register
mail settings
Submitter Pierre-Yves David
Date Oct. 16, 2014, 9:30 a.m.
Message ID <b1c281d9e3f520f01373.1413451809@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/6322/
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 1413450306 25200
#      Thu Oct 16 02:05:06 2014 -0700
# Node ID b1c281d9e3f520f013736d74f6f1e239d0dd94d1
# Parent  2dabd90d3490e271f164a8992b86550dc3e0dfd3
repoview: add a FilteredLookupError class

This exception is a more precise LookupError 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
@@ -188,11 +188,12 @@  class changelog(revlog.revlog):
 
     def rev(self, node):
         """filtered version of revlog.rev"""
         r = super(changelog, self).rev(node)
         if r in self.filteredrevs:
-            raise error.LookupError(hex(node), self.indexfile, _('no node'))
+            raise error.FilteredLookupError(hex(node), self.indexfile,
+                                            _('filtered node'))
         return r
 
     def node(self, rev):
         """filtered version of revlog.node"""
         if rev in self.filteredrevs:
diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -28,10 +28,13 @@  class LookupError(RevlogError, KeyError)
         RevlogError.__init__(self, '%s@%s: %s' % (index, name, message))
 
     def __str__(self):
         return RevlogError.__str__(self)
 
+class FilteredLookupError(LookupError):
+    pass
+
 class ManifestLookupError(LookupError):
     pass
 
 class CommandError(Exception):
     """Exception raised on errors in parsing the command line."""