Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/utils/storageutil.py @ 50029:5698c5eee12b
storageutil: match node length with repository
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Thu, 29 Apr 2021 22:01:04 +0200 |
parents | e0c0545e2e55 |
children | f4733654f144 |
comparison
equal
deleted
inserted
replaced
50028:380ed77e9ad3 | 50029:5698c5eee12b |
---|---|
188 | 188 |
189 ``store`` is an object implementing the ``ifileindex`` interface. | 189 ``store`` is an object implementing the ``ifileindex`` interface. |
190 | 190 |
191 ``fileid`` can be: | 191 ``fileid`` can be: |
192 | 192 |
193 * A 20 or 32 byte binary node. | 193 * A binary node of appropiate size (e.g. 20/32 Bytes). |
194 * An integer revision number | 194 * An integer revision number |
195 * A 40 or 64 byte hex node. | 195 * A hex node of appropiate size (e.g. 40/64 Bytes). |
196 * A bytes that can be parsed as an integer representing a revision number. | 196 * A bytes that can be parsed as an integer representing a revision number. |
197 | 197 |
198 ``identifier`` is used to populate ``error.LookupError`` with an identifier | 198 ``identifier`` is used to populate ``error.LookupError`` with an identifier |
199 for the store. | 199 for the store. |
200 | 200 |
206 except IndexError: | 206 except IndexError: |
207 raise error.LookupError( | 207 raise error.LookupError( |
208 b'%d' % fileid, identifier, _(b'no match found') | 208 b'%d' % fileid, identifier, _(b'no match found') |
209 ) | 209 ) |
210 | 210 |
211 if len(fileid) in (20, 32): | 211 if len(fileid) == len(store.nullid): |
212 try: | 212 try: |
213 store.rev(fileid) | 213 store.rev(fileid) |
214 return fileid | 214 return fileid |
215 except error.LookupError: | 215 except error.LookupError: |
216 pass | 216 pass |
217 | 217 |
218 if len(fileid) in (40, 64): | 218 if len(fileid) == 2 * len(store.nullid): |
219 try: | 219 try: |
220 rawnode = bin(fileid) | 220 rawnode = bin(fileid) |
221 store.rev(rawnode) | 221 store.rev(rawnode) |
222 return rawnode | 222 return rawnode |
223 except TypeError: | 223 except TypeError: |