comparison mercurial/testing/storage.py @ 40003:ad8389ecd3f5

storageutil: consistently raise LookupError (API) The interface docs say this is supposed to raise LookupError on failure. But for invalid revision number input, it could raise IndexError because ifileindex.node() is documented to raise IndexError. lookup() for files isn't used that much (pretty much just in basefilectx in core AFAICT). And callers should already be catching LookupError. So I don't anticipate that much fallout from this change. Differential Revision: https://phab.mercurial-scm.org/D4798
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 28 Sep 2018 11:16:44 -0700
parents 0e8836be9541
children 8e398628a3f2
comparison
equal deleted inserted replaced
40002:0e8836be9541 40003:ad8389ecd3f5
197 self.assertEqual(f.lookup(hex(node)), node) 197 self.assertEqual(f.lookup(hex(node)), node)
198 198
199 with self.assertRaises(error.LookupError): 199 with self.assertRaises(error.LookupError):
200 f.lookup(hex(node)[0:12]) 200 f.lookup(hex(node)[0:12])
201 201
202 with self.assertRaises(IndexError): 202 with self.assertRaises(error.LookupError):
203 f.lookup(-2) 203 f.lookup(-2)
204 204
205 with self.assertRaises(error.LookupError): 205 with self.assertRaises(error.LookupError):
206 f.lookup(b'-2') 206 f.lookup(b'-2')
207 207
208 with self.assertRaises(IndexError): 208 with self.assertRaises(error.LookupError):
209 f.lookup(1) 209 f.lookup(1)
210 210
211 with self.assertRaises(error.LookupError): 211 with self.assertRaises(error.LookupError):
212 f.lookup(b'1') 212 f.lookup(b'1')
213 213