Patchwork D3092: simplestore: shore up lookup errors

login
register
mail settings
Submitter phabricator
Date April 6, 2018, 7:50 p.m.
Message ID <59866d14c3cec501e9a51f768e383ce7@localhost.localdomain>
Download mbox | patch
Permalink /patch/30458/
State Not Applicable
Headers show

Comments

phabricator - April 6, 2018, 7:50 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGdd2753729853: simplestore: shore up lookup errors (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3092?vs=7674&id=7802

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

AFFECTED FILES
  tests/simplestorerepo.py

CHANGE DETAILS




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

Patch

diff --git a/tests/simplestorerepo.py b/tests/simplestorerepo.py
--- a/tests/simplestorerepo.py
+++ b/tests/simplestorerepo.py
@@ -152,8 +152,10 @@ 
     def rev(self, node):
         validatenode(node)
 
-        # Will raise KeyError.
-        self._indexbynode[node]
+        try:
+            self._indexbynode[node]
+        except KeyError:
+            raise error.LookupError(node, self._indexpath, _('no node'))
 
         for rev, entry in self._indexbyrev.items():
             if entry[b'node'] == node:
@@ -171,11 +173,8 @@ 
             return self.node(node)
 
         if len(node) == 20:
-            try:
-                self.rev(node)
-                return node
-            except LookupError:
-                pass
+            self.rev(node)
+            return node
 
         try:
             rev = int(node)
@@ -196,10 +195,10 @@ 
                 rawnode = bin(node)
                 self.rev(rawnode)
                 return rawnode
-            except (TypeError, LookupError):
+            except TypeError:
                 pass
 
-        raise LookupError(node, self._path, _('invalid lookup input'))
+        raise error.LookupError(node, self._path, _('invalid lookup input'))
 
     def linkrev(self, rev):
         validaterev(rev)
@@ -280,8 +279,6 @@ 
         if node == nullid:
             return b''
 
-        self._indexbynode[node]
-
         rev = self.rev(node)
         flags = self.flags(rev)