comparison mercurial/utils/storageutil.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 fa3dc85a747e
comparison
equal deleted inserted replaced
40002:0e8836be9541 40003:ad8389ecd3f5
119 for the store. 119 for the store.
120 120
121 Raises ``error.LookupError`` on failure. 121 Raises ``error.LookupError`` on failure.
122 """ 122 """
123 if isinstance(fileid, int): 123 if isinstance(fileid, int):
124 return store.node(fileid) 124 try:
125 return store.node(fileid)
126 except IndexError:
127 raise error.LookupError(fileid, identifier, _('no match found'))
125 128
126 if len(fileid) == 20: 129 if len(fileid) == 20:
127 try: 130 try:
128 store.rev(fileid) 131 store.rev(fileid)
129 return fileid 132 return fileid