changeset 39775:974592474dee

revlog: drop LookupError alias (API) This alias is especially bad because it shadows the built-in LookupError type. This has caused me confusion in the past when reading revlog code. Qualifying all uses with "error." will make it obvious that we're using a Mercurial error type. Differential Revision: https://phab.mercurial-scm.org/D4653
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 18 Sep 2018 16:28:17 -0700
parents 4a2466b2a434
children cb65d4b7e429
files mercurial/revlog.py
diffstat 1 files changed, 11 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlog.py	Tue Sep 18 16:24:36 2018 -0700
+++ b/mercurial/revlog.py	Tue Sep 18 16:28:17 2018 -0700
@@ -104,8 +104,6 @@
 _maxinline = 131072
 _chunksize = 1048576
 
-LookupError = error.LookupError
-
 # Store flag processors (cf. 'addflagprocessor()' to register)
 _flagprocessors = {
     REVIDX_ISCENSORED: None,
@@ -619,7 +617,7 @@
             # parsers.c radix tree lookup failed
             if node == wdirid or node in wdirfilenodeids:
                 raise error.WdirUnsupported
-            raise LookupError(node, self.indexfile, _('no node'))
+            raise error.LookupError(node, self.indexfile, _('no node'))
         except KeyError:
             # pure python cache lookup failed
             n = self._nodecache
@@ -637,7 +635,7 @@
                     return r
             if node == wdirid or node in wdirfilenodeids:
                 raise error.WdirUnsupported
-            raise LookupError(node, self.indexfile, _('no node'))
+            raise error.LookupError(node, self.indexfile, _('no node'))
 
     # Accessors for index entries.
 
@@ -1235,7 +1233,7 @@
                 node = id
                 self.rev(node) # quick search the index
                 return node
-            except LookupError:
+            except error.LookupError:
                 pass # may be partial hex id
         try:
             # str(rev)
@@ -1255,7 +1253,7 @@
                 node = bin(id)
                 self.rev(node)
                 return node
-            except (TypeError, LookupError):
+            except (TypeError, error.LookupError):
                 pass
 
     def _partialmatch(self, id):
@@ -1320,7 +1318,7 @@
         if n:
             return n
 
-        raise LookupError(id, self.indexfile, _('no match found'))
+        raise error.LookupError(id, self.indexfile, _('no match found'))
 
     def shortest(self, node, minlength=1):
         """Find the shortest unambiguous prefix that matches node."""
@@ -1333,7 +1331,7 @@
                 # single 'ff...' match
                 return True
             if node is None:
-                raise LookupError(node, self.indexfile, _('no node'))
+                raise error.LookupError(node, self.indexfile, _('no node'))
             return True
 
         def maybewdir(prefix):
@@ -1354,7 +1352,7 @@
                 return disambiguate(hexnode, length)
             except error.RevlogError:
                 if node != wdirid:
-                    raise LookupError(node, self.indexfile, _('no node'))
+                    raise error.LookupError(node, self.indexfile, _('no node'))
             except AttributeError:
                 # Fall through to pure code
                 pass
@@ -2085,12 +2083,12 @@
 
                 for p in (p1, p2):
                     if p not in self.nodemap:
-                        raise LookupError(p, self.indexfile,
-                                          _('unknown parent'))
+                        raise error.LookupError(p, self.indexfile,
+                                                _('unknown parent'))
 
                 if deltabase not in self.nodemap:
-                    raise LookupError(deltabase, self.indexfile,
-                                      _('unknown delta base'))
+                    raise error.LookupError(deltabase, self.indexfile,
+                                            _('unknown delta base'))
 
                 baserev = self.rev(deltabase)