comparison mercurial/utils/storageutil.py @ 45404:c4a4a49589bf

storageutil: allow modern hash sizes for fileids Differential Revision: https://phab.mercurial-scm.org/D8783
author Joerg Sonnenberger <joerg@bec.de>
date Tue, 21 Jul 2020 22:41:45 +0200
parents 9d2b2df2c2ba
children e8c11a2c96c0
comparison
equal deleted inserted replaced
45403:6a0e7bf73bb2 45404:c4a4a49589bf
178 178
179 ``store`` is an object implementing the ``ifileindex`` interface. 179 ``store`` is an object implementing the ``ifileindex`` interface.
180 180
181 ``fileid`` can be: 181 ``fileid`` can be:
182 182
183 * A 20 byte binary node. 183 * A 20 or 32 byte binary node.
184 * An integer revision number 184 * An integer revision number
185 * A 40 byte hex node. 185 * A 40 or 64 byte hex node.
186 * A bytes that can be parsed as an integer representing a revision number. 186 * A bytes that can be parsed as an integer representing a revision number.
187 187
188 ``identifier`` is used to populate ``error.LookupError`` with an identifier 188 ``identifier`` is used to populate ``error.LookupError`` with an identifier
189 for the store. 189 for the store.
190 190
196 except IndexError: 196 except IndexError:
197 raise error.LookupError( 197 raise error.LookupError(
198 b'%d' % fileid, identifier, _(b'no match found') 198 b'%d' % fileid, identifier, _(b'no match found')
199 ) 199 )
200 200
201 if len(fileid) == 20: 201 if len(fileid) in (20, 32):
202 try: 202 try:
203 store.rev(fileid) 203 store.rev(fileid)
204 return fileid 204 return fileid
205 except error.LookupError: 205 except error.LookupError:
206 pass 206 pass
207 207
208 if len(fileid) == 40: 208 if len(fileid) in (40, 64):
209 try: 209 try:
210 rawnode = bin(fileid) 210 rawnode = bin(fileid)
211 store.rev(rawnode) 211 store.rev(rawnode)
212 return rawnode 212 return rawnode
213 except TypeError: 213 except TypeError: